Problem with vba directory function

J

Jack

Hi
We have an access application that has a button when clicked opens an excel
worksheet showing all exported data based on code

The access sql system is in Citrix with a single front end copy.

Here is the code part that is throwing the error for just one user.
Rest all are working fine


Dim strSourceFileName As String
Dim WorkBookName As String




strSourceFileName = "c:\CarLogOutPut\CarLogExportTemplate.xls"
WorkBookName = "c:\CarLogOutPut\CarLogExport.xls"


If Dir(strSourceFileName) = "" Then
MsgBox "CarLogExportTemplate.xls does not exist. It must exist for
processing", vbInformation, "File does not exist"
Exit Sub
End If

In the above
when I am stepping through the code I am getting the proper
strSourceFileName when I am hovering my mouse over strSourceFileName
in the following code
If Dir(strSourceFileName)

However the Dir(strSourceFileName) gives me "" and the
len((strSourceFileName,vbDirectory))
gives me 0.

I am not sure why this is happening and thus
code enters the MessageBox instead of running with the rest.

I appreciate any help for resolution of this issue.
Thanks.
 
S

Stuart McCall

Jack said:
Hi
We have an access application that has a button when clicked opens an
excel
worksheet showing all exported data based on code

The access sql system is in Citrix with a single front end copy.

Here is the code part that is throwing the error for just one user.
Rest all are working fine


Dim strSourceFileName As String
Dim WorkBookName As String




strSourceFileName = "c:\CarLogOutPut\CarLogExportTemplate.xls"
WorkBookName = "c:\CarLogOutPut\CarLogExport.xls"


If Dir(strSourceFileName) = "" Then
MsgBox "CarLogExportTemplate.xls does not exist. It must exist for
processing", vbInformation, "File does not exist"
Exit Sub
End If

In the above
when I am stepping through the code I am getting the proper
strSourceFileName when I am hovering my mouse over strSourceFileName
in the following code
If Dir(strSourceFileName)

However the Dir(strSourceFileName) gives me "" and the
len((strSourceFileName,vbDirectory))
gives me 0.

I am not sure why this is happening and thus
code enters the MessageBox instead of running with the rest.

I appreciate any help for resolution of this issue.
Thanks.

Well your code is perfectly ok, so it has to be the user's setup that's
causing the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top