Run AutoExec macro in the backend access db (1 Viewer)

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
Hi all ^_^

How can I make an autoExec macro runs in the backend split access db when a user opens a frontend db

The macro is for ImportExportData .......I use it as a back up method......so i need the original tables to be copied not the linked ones......

thanks in advance :D
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:05
Joined
Oct 29, 2018
Messages
21,468
Hi. Where are you backing up the data into? Maybe you can take a look at this backup function as an alternate approach.
 

isladogs

MVP / VIP
Local time
Today, 18:05
Joined
Jan 14, 2017
Messages
18,216
You wouldn't do so.
The BE file should normally be tables only
Move the code to your FE and run it as an autoexec or from a button click

AND...the linked tables are the original ones!.
These are only copies if you import the tables instead of linking them ...or convert the linked tables to local
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
Hi. Where are you backing up the data into? Maybe you can take a look at this backup function as an alternate approach.

hi :)

I backup my data on the same computer until they manage a space on the server

it works great in the FE but it exports the linked tables that means any damage may happen to the shared BE db means no data ....

BTW many users use the data base from different computers
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
You wouldn't do so.
The BE file should normally be tables only
Move the code to your FE and run it as an autoexec or from a button click

AND...the linked tables are the original ones!.
These are only copies if you import the tables instead of linking them ...or convert the linked tables to local

hi :)

may you explain more ...i am an access beginner user .....
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:05
Joined
Oct 29, 2018
Messages
21,468
hi :)

I backup my data on the same computer until they manage a space on the server

it works great in the FE but it exports the linked tables that means any damage may happen to the shared BE db means no data ....

BTW many users use the data base from different computers
Hi. Can you show us your backup routine or could you give the function I linked to earlier a try?
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
Hi. Can you show us your backup routine or could you give the function I linked to earlier a try?

I simply use this macro to get may goal.....do not use VBA a lot as a beginner


 

Attachments

  • Picture1.jpg
    Picture1.jpg
    89.8 KB · Views: 483

theDBguy

I’m here to help
Staff member
Local time
Today, 10:05
Joined
Oct 29, 2018
Messages
21,468
I simply use this macro to get may goal.....do not use VBA a lot as a beginner
Hi. Unfortunately, even if we continue to use your BE's Autoexec macro, I think we would still need to use VBA to execute it from the FE. So, if we use VBA, we might as well do the backup from the FE and not even have any code in the BE at all. I tried to look for a macro equivalent of FileCopy, but I couldn't, unless I missed it.
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
Hi. Unfortunately, even if we continue to use your BE's Autoexec macro, I think we would still need to use VBA to execute it from the FE. So, if we use VBA, we might as well do the backup from the FE and not even have any code in the BE at all. I tried to look for a macro equivalent of FileCopy, but I couldn't, unless I missed it.

Many thanks

what do you suggest then?? I am :confused:
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:05
Joined
Oct 29, 2018
Messages
21,468
Many thanks

what do you suggest then?? I am :confused:
My first suggestion is to use the backup function I linked to earlier in your FE. What it does, when executed, is create a backup copy of the BE file and then compact it. The backup copy is tagged with the date and time when it was backed up in the filename. Give it a try and let us know if you get stuck, and we'll walk you through it. So, the first step is to copy and paste the code from the website to a Standard Module in your FE.

PS. Here's the link again, just in case you need it.
 

isladogs

MVP / VIP
Local time
Today, 18:05
Joined
Jan 14, 2017
Messages
18,216
hi :)

may you explain more ...i am an access beginner user .....

When you link to an external Access table, it is 'live'. Changes made to table data from the FE means the BE tables are modified.

If you import a table, you are importing a snapshot of that table at that moment in time. Changes to the data in the FE will not affect the BE table as it is totally separate.

It is also possible to convert a linked table to a local table in the FE. It is then totally separate from the BE table and its behaviour will be the same as described for an imported table.

Hope that makes sense
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
Does RunApplication as an AutoExec macro in the FE be a solution???

to open the BE and then the export data autoExce macro runs.....

or it does not work!!!!!!

:confused::confused::confused:
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
My first suggestion is to use the backup function I linked to earlier in your FE. What it does, when executed, is create a backup copy of the BE file and then compact it. The backup copy is tagged with the date and time when it was backed up in the filename. Give it a try and let us know if you get stuck, and we'll walk you through it. So, the first step is to copy and paste the code from the website to a Standard Module in your FE.

PS. Here's the link again, just in case you need it.

OK
I will work on that
many thanks for your help
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
When you link to an external Access table, it is 'live'. Changes made to table data from the FE means the BE tables are modified.

If you import a table, you are importing a snapshot of that table at that moment in time. Changes to the data in the FE will not affect the BE table as it is totally separate.

It is also possible to convert a linked table to a local table in the FE. It is then totally separate from the BE table and its behaviour will be the same as described for an imported table.

Hope that makes sense

i got it now
many thanks and i will keep trying
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
My first suggestion is to use the backup function I linked to earlier in your FE. What it does, when executed, is create a backup copy of the BE file and then compact it. The backup copy is tagged with the date and time when it was backed up in the filename. Give it a try and let us know if you get stuck, and we'll walk you through it. So, the first step is to copy and paste the code from the website to a Standard Module in your FE.

PS. Here's the link again, just in case you need it.

I did the first step
I copied the code and pasted it in new module and named it backup
and did this too
"Note: Replace "tblHidden" with the name of one of your linked tables in the BE and replace "\SCR_BE" with the actual name of your BE file."
then :) .... what
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 10:05
Joined
Oct 29, 2018
Messages
21,468
I did the first step
I copied the code and pasted it in new module and named it backup
then :) .... what
Okay, you'll have to modify the code in a couple of places. What is the name of one of your linked tables? And I assume all tables are linked to the same BE file, correct?
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
Okay, you'll have to modify the code in a couple of places. What is the name of one of your linked tables? And I assume all tables are linked to the same BE file, correct?

yes and i did those changes
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:05
Joined
Oct 29, 2018
Messages
21,468
yes and i did those changes
Okay. The next step is to test it. From the Immediate Window, enter the following:
Code:
BackupAndCompactBE
If you didn't get an error, check the folder where your FE is located to see if you see the backup file there.
 

AsMok

IT IS ME ^_^
Local time
Today, 10:05
Joined
Sep 4, 2019
Messages
64
QUOTE=theDBguy;1647961]Okay. The next step is to test it. From the Immediate Window, enter the following:
Code:
BackupAndCompactBE
If you didn't get an error, check the folder where your FE is located to see if you see the backup file there.[/QUOTE]



GREAT :D
 

Attachments

  • Picture1.jpg
    Picture1.jpg
    41.4 KB · Views: 371

Users who are viewing this thread

Top Bottom