RobertIngles
Technical User
Hello All;
Using Access 2007.
I have added a browse button to a form using the MS Common Dialog Control to open the browsing window and then I want a text box to display the path of the file selected. I found the code I need in a post and have copied it to my form's module. The browser window opens up just the way I want and the author says that by selecting a file and then clicking the "Open" button the path should appear in the text box. Uunfortunatley it doesn't. Here is the code - can anyone pinpoint why it wouldn't populate the field? I thought that the line Me!lbldb = VFile might be the problem as I had not named the unbound text field but have played with it for awhile and no luck.
Private Sub cmdBrowse_Click()
Dim VFile As String
On Error GoTo cmdBrowse_Click_Err
ChDrive ("C")
ChDir ("C:\")
cmDialog1.Filter = "All Files (*.*)|*.*|cmDialog1.FilterIndex = 1
cmDialog1.Action = 1
If cmDialog1.FileName = "" Then
VFile = cmDialog1.FileName
Me!lbldb = VFile
End If
cmdBrowse_Click_Exit:
Exit Sub
cmdBrowse_Click_Err:
MsgBox Err.Description, , "cmdBrowse_Click"
Resume cmdBrowse_Click_Exit
End Sub
Thanks everyone!
Using Access 2007.
I have added a browse button to a form using the MS Common Dialog Control to open the browsing window and then I want a text box to display the path of the file selected. I found the code I need in a post and have copied it to my form's module. The browser window opens up just the way I want and the author says that by selecting a file and then clicking the "Open" button the path should appear in the text box. Uunfortunatley it doesn't. Here is the code - can anyone pinpoint why it wouldn't populate the field? I thought that the line Me!lbldb = VFile might be the problem as I had not named the unbound text field but have played with it for awhile and no luck.
Private Sub cmdBrowse_Click()
Dim VFile As String
On Error GoTo cmdBrowse_Click_Err
ChDrive ("C")
ChDir ("C:\")
cmDialog1.Filter = "All Files (*.*)|*.*|cmDialog1.FilterIndex = 1
cmDialog1.Action = 1
If cmDialog1.FileName = "" Then
VFile = cmDialog1.FileName
Me!lbldb = VFile
End If
cmdBrowse_Click_Exit:
Exit Sub
cmdBrowse_Click_Err:
MsgBox Err.Description, , "cmdBrowse_Click"
Resume cmdBrowse_Click_Exit
End Sub
Thanks everyone!