copy current database (1 Viewer)

senseidan

Registered User.
Local time
Today, 02:27
Joined
Jan 25, 2018
Messages
38
I need to make a copy of my current database to a certain location that can be changed.
For this I use a piece of code that works very well in full access but gives a fatal error when running in runtime.
After investigating the case, I came to the conclusion that the error occurs when the variable that stores the destination path takes its value from the table in which it is stored.
If I write this path directly in the code, both versions, access and runtime, work.
If, as I said, I use dlookup to extract a path from the table, the runtime version gives me the message "Execution of this application has stopped due to a run-time error. The application can't continue and will be shutdown."
At this point I was left with no idea what I could try. Can someone help me?
 

senseidan

Registered User.
Local time
Today, 02:27
Joined
Jan 25, 2018
Messages
38
Thank you, Minty. You were fast.
Interesting the link you sent me but, I must say, the runtime switch is ineffective.
I am struggling with 2 computers because I did not find a reliable method to test runtime on the same computer on which full access is installed. The last unpleasant surprise in this area is the program I am discussing, that I tested using a switch proven ineffective.
Meanwhile, I narrowed my search further and found that what is causing the error is the part of the path that contains the generic reference to the user's name: …" & Environ("UserName") & "\...
If I replace this portion with the specific name, it works in runtime.
This is a solution that satisfies me in part.
I assume the error comes from the fact that when I write the path directly, the user's name is extracted by the code but, when I force the variable to read the path from the table, the portion with "Environ ..." is taken as such and does not extract the user's name as expected.
 

Solo712

Registered User.
Local time
Yesterday, 21:27
Joined
Oct 19, 2012
Messages
828
Thank you, Minty. You were fast.
Interesting the link you sent me but, I must say, the runtime switch is ineffective.
I am struggling with 2 computers because I did not find a reliable method to test runtime on the same computer on which full access is installed. The last unpleasant surprise in this area is the program I am discussing, that I tested using a switch proven ineffective.
Meanwhile, I narrowed my search further and found that what is causing the error is the part of the path that contains the generic reference to the user's name: …" & Environ("UserName") & "\...
If I replace this portion with the specific name, it works in runtime.
This is a solution that satisfies me in part.
I assume the error comes from the fact that when I write the path directly, the user's name is extracted by the code but, when I force the variable to read the path from the table, the portion with "Environ ..." is taken as such and does not extract the user's name as expected.

Hi, have you tried to find out what the path name looks like by putting a watch on it and break the code before the error occurs? Incidentally, you may be better off referring to your path as Application.CurrentProject.path which takes care of the possibility the path changes with different users.

Best,
Jiri
 

Users who are viewing this thread

Top Bottom