Hello all,
I have what I thought was easy, but obviously doing something wrong, as a non-programmer. I've checked the Access board here for similar issues too:
First, I am setting up a folder from a button, with a small sub and function on the button click. First issue is, the folder will correctly show in the text box, and then it later DISAPPEARS on from the text box! I have never seen a text box value cleared, without some user action or sub code.
Public Sub cmdBrowserButton_Click()
Dim strChoice As String
strChoice = FolderSelection
If Len(strChoice) > 0 Then
Me.txtForBrowser.Value = strChoice
Else
Close
End If
End Sub
Public Function FolderSelection() As String
Dim objFD As Object
Dim strOut As String
strOut = vbNullString
'msoFileDialogFolderPicker = 4
Set objFD = Application.FileDialog(4)
If objFD.Show = -1 Then
strOut = objFD.SelectedItems(1)
End If
Set objFD = Nothing
FolderSelection = strOut
End Function
My hope is, after the folder is PERMANENTLY set in the form's text box, I can then later on use it when I export a query out to Excel, per this code:
'Set the Folder path for Exporting Query to Excel
strPath = Forms![frmMainMenu]![txtForBrowser].Value
So, the sub that should export the query, cycles through okay, but the destination template file (xltm), where I'm hoping to see the exported data, is untouched and unchanged.
I've tried many different versions of the above code snips, but think the above are the closest to being good. I'm confounded...why is the folder properly populated in the form text box, and then disappears??
Thanks in advance for any response, PW
I have what I thought was easy, but obviously doing something wrong, as a non-programmer. I've checked the Access board here for similar issues too:
First, I am setting up a folder from a button, with a small sub and function on the button click. First issue is, the folder will correctly show in the text box, and then it later DISAPPEARS on from the text box! I have never seen a text box value cleared, without some user action or sub code.
Public Sub cmdBrowserButton_Click()
Dim strChoice As String
strChoice = FolderSelection
If Len(strChoice) > 0 Then
Me.txtForBrowser.Value = strChoice
Else
Close
End If
End Sub
Public Function FolderSelection() As String
Dim objFD As Object
Dim strOut As String
strOut = vbNullString
'msoFileDialogFolderPicker = 4
Set objFD = Application.FileDialog(4)
If objFD.Show = -1 Then
strOut = objFD.SelectedItems(1)
End If
Set objFD = Nothing
FolderSelection = strOut
End Function
My hope is, after the folder is PERMANENTLY set in the form's text box, I can then later on use it when I export a query out to Excel, per this code:
'Set the Folder path for Exporting Query to Excel
strPath = Forms![frmMainMenu]![txtForBrowser].Value
So, the sub that should export the query, cycles through okay, but the destination template file (xltm), where I'm hoping to see the exported data, is untouched and unchanged.
I've tried many different versions of the above code snips, but think the above are the closest to being good. I'm confounded...why is the folder properly populated in the form text box, and then disappears??
Thanks in advance for any response, PW