Hi guys, this is my first post. I've been working with MS Access for awhile but I'm not an export, I mostly work with recordsets and basic coding.
What I'm trying to do now is have a textbox in my main form where the user enters a default path, eg C:\DATA then I have the following code:
Dim strFileName As String
Dim xlApplication As Excel.Application
Dim strInitDir As String
Set xlApplication = New Excel.Application
'set the path to the textbox on the main form
strInitDir = Form_frm_Main_Menu.txtDir.Value
If IsNull(strInitDir) Or strInitDir = "" Then
strInitDir = "C:\DATA"
End If
xlApplication.DefaultFilePath = strInitDir
strFileName = xlApplication.GetOpenFilename("Excel Files (*.xls), *.xls")
Now here is the problem I'm having. The first time I run the program, it opens to the right filepath. Now if I change the filepath on the main form and run the program again, it will go to the original file path. If I run it a third time it will go to the file path I had previously entered. It seems the code is always 1 entry behind what I want.
I'd appreciate any help, thanks!
What I'm trying to do now is have a textbox in my main form where the user enters a default path, eg C:\DATA then I have the following code:
Dim strFileName As String
Dim xlApplication As Excel.Application
Dim strInitDir As String
Set xlApplication = New Excel.Application
'set the path to the textbox on the main form
strInitDir = Form_frm_Main_Menu.txtDir.Value
If IsNull(strInitDir) Or strInitDir = "" Then
strInitDir = "C:\DATA"
End If
xlApplication.DefaultFilePath = strInitDir
strFileName = xlApplication.GetOpenFilename("Excel Files (*.xls), *.xls")
Now here is the problem I'm having. The first time I run the program, it opens to the right filepath. Now if I change the filepath on the main form and run the program again, it will go to the original file path. If I run it a third time it will go to the file path I had previously entered. It seems the code is always 1 entry behind what I want.
I'd appreciate any help, thanks!