I have created Browse buttons on my userform that open the file dialogue box, and allow me to select a file location. The file name text gets inserted into a corresponding text box. When the userform is submitted, the information goes to a database and is distribtued on the first empty row. The file names get inserted into cells, and I would like for the file names to act as hyperlinks to that specific file location. When I first created this workbook, I could click on the file location, and the file would open, but it is not doing that any longer. I think if the userform can insert the file location as a hyperlink, it will be more user-friendly. Here is the code I have so far:
Private Sub BrowseButton_Click()
'Browse for file
Dim fullfilename As String
filename = Application.GetOpenFilename()
txtAttachChit.Value = filename
txtAttachChit.SetFocus
End Sub
Private Sub BrowseButton2_Click()
'Browse for file
Dim filename As String
filename = Application.GetOpenFilename()
txtAttachOther.Value = filename
txtAttachOther.SetFocus
End Sub
Private Sub cmdClose_Click()
frmInquiry.Hide
End Sub
Private Sub cmdUpdate_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Master Inquiry")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for an Inquiry Date
If Trim(Me.txtInquiryDate.Value) = "" Then
Me.txtInquiryDate.SetFocus
MsgBox "Please enter an Inquiry Date", vbOKOnly, "Entry Required"
Exit Sub
End If
With ws
If OptionButton1.Value = True Then
.Cells(iRow, 1).Value = "F&B"
End If
If OptionButton2.Value = True Then
.Cells(iRow, 1).Value = "Golf"
End If
If OptionButton3.Value = True Then
.Cells(iRow, 1).Value = "Sports"
End If
If OptionButton4.Value = True Then
.Cells(iRow, 1).Value = "Events"
End If
If OptionButton5.Value = True Then
.Cells(iRow, 1).Value = "Membership"
End If
If OptionButton6.Value = True Then
.Cells(iRow, 1).Value = "Other"
End If
.Cells(iRow, 2).Value = Me.txtInquiryDate.Value
.Cells(iRow, 3).Value = Me.txtMemberName.Value
.Cells(iRow, 4).Value = Me.txtMemberNumber.Value
.Cells(iRow, 5).Value = Me.txtPhoneNumber.Value
.Cells(iRow, 6).Value = Me.txtDate.Value
.Cells(iRow, 7).Value = Me.txtAmount.Value
.Cells(iRow, 8).Value = Me.txtDescription
.Cells(iRow, 9).Value = Me.txtAttachChit
.Cells(iRow, 10).Value = Me.txtAttachOther
.Cells(iRow, 11).Value = Me.txtSentBy.Value
.Cells(iRow, 13).Value = "Outstanding"
End With
'clear the data
Me.txtInquiryDate.Value = ""
Me.txtMemberName.Value = ""
Me.txtMemberNumber.Value = ""
Me.txtPhoneNumber.Value = ""
Me.txtDate.Value = ""
Me.txtAmount.Value = ""
Me.txtDescription = ""
Me.txtDescription = ""
Me.txtAttachChit = ""
Me.txtAttachOther = ""
Me.txtSentBy = ""
Me.OptionButton1 = False
Me.OptionButton2 = False
Me.OptionButton3 = False
Me.OptionButton4 = False
Me.OptionButton5 = False
Me.OptionButton6 = False
Me.txtInquiryDate.SetFocus
End Sub
Bookmarks