copy macros to another access DB (1 Viewer)

Sarameier

New member
Local time
Today, 15:57
Joined
Sep 3, 2021
Messages
26
Dear all...

There is this great macro "for opening a form by click"


My question: Apart from copy & pasting the XML block, is there a way to bringing this macro from one Access DB to another?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:57
Joined
May 21, 2018
Messages
8,529
Import from the database
import.jpg
 

Sarameier

New member
Local time
Today, 15:57
Joined
Sep 3, 2021
Messages
26
but applying this function: The embedded macro from "on dbl click" would not appear to be copied
1.PNG
2.PNG
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:57
Joined
May 21, 2018
Messages
8,529
Did you import the macro or just the form? I do not use macros but modules have to be imported separately even if the form calls it. I assume the same.
 

Sarameier

New member
Local time
Today, 15:57
Joined
Sep 3, 2021
Messages
26
I tried to import the macro, but there would only the form be available. The thing is that I want to use this macro for other forms other than the inherent one...

I thought there might be a way to just copy paste it to other forms
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:57
Joined
May 21, 2018
Messages
8,529
Sorry, I do not know how to do macros. Hopefully someone can help. I sometimes build an autoexec, that is about it. I have never built a macro where you can set the arguments and parameters. If you want reusable code you are likely better off with VBA. Will be a lot easier to get people to help with that.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:57
Joined
Oct 29, 2018
Messages
21,474
I thought there might be a way to just copy paste it to other forms
Hi. I'm not in front of a computer now, but have you tried selecting the entire macro and then copy and paste it to the other form?
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:57
Joined
Sep 21, 2011
Messages
14,311
If it is embedded, you need to either export the form/report from your DB, or import from new DB?
Alternatively, you can save as a standalone macro and import/export that directly?

You can even just copy the object that runs the embedded macro between DBs. I just tested with a command button.
 

isladogs

MVP / VIP
Local time
Today, 14:57
Joined
Jan 14, 2017
Messages
18,236
I also never use macros apart from autoexec & autokeys.
However, several years ago I did some research on ways of reading/editing macros using code.

Macros are saved as XML which means there is a lot of 'gobblygook' included.
It is tricky to copy & paste macros to another form (though not impossible)

Effectively, embedded macros are exactly that .... they cannot be copied to another location

You can try the method Gasman suggested but, in the end, you would be better off changing from using macros to VBA code
 

mike60smart

Registered User.
Local time
Today, 14:57
Joined
Aug 6, 2017
Messages
1,911
As Colin has said, it is far easier to use VBA.

In this case where you have Multiple Records on a Form, and you need to open another form linked by the specific Primary Key,
it is easier to use the Open Args Method.
 

Attachments

  • Open Args.zip
    6.4 KB · Views: 324

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:57
Joined
Feb 19, 2002
Messages
43,293
The VBA to perform this action is only a single line of code. It uses the OpenForm method. The arguments specify the form to open and the where clause passes the ID of the record so that the form will open to the record you click on.

If you can't manage to create the VBA without help, you can use the button on the ribbon to convert the embedded macros to VBA. Who knows what they do. Hopefully you will see the OpenForm instruction. Access has many features to "help" the novice. Most of them should be avoided.
 

Users who are viewing this thread

Top Bottom