Andy Brown
asked on
Moving a .BAS file into an external database
I need to create a .BAS file which is pushed into an external Access .mdb file. Any suggestions?
Are your trying to take a module from one db and make a copy of it into another db?
If you open up a given module ... then File>>Export File ...
the Windows dialog box comes up ... and the SaveAs is already set to .BAS
mx
the Windows dialog box comes up ... and the SaveAs is already set to .BAS
mx
ASKER
Thanks guys.
I create the VBA on the fly as it is to do with a security feature. Historically, I have created the.BAS file, imported it into the open database (running the function) and then exported it to the destination. When I run this function it may upgrade 40+ databases (all with different VBA scripts) and it seems to be really slow.
If I could send the .BAS file into the destination .mdb database, i'm sure it would speed things up.
I create the VBA on the fly as it is to do with a security feature. Historically, I have created the.BAS file, imported it into the open database (running the function) and then exported it to the destination. When I run this function it may upgrade 40+ databases (all with different VBA scripts) and it seems to be really slow.
If I could send the .BAS file into the destination .mdb database, i'm sure it would speed things up.
Well, on the flip side ... you can then Import that .bas file into the other mdb. Not sure how this can be automated, which is what you are after, right ?
mx
mx
Does this .bas file change over time, or is it static? If it's static, you could just include a module that created your module - although I'm not sure how well that would work.
You could also use Application.LoadFromText(a cModule, "YourModuleName", "full path to the module.txt file")
Note that LoadFromText expects the incoming file to be in a specific format, so be aware of that.
You could also use Application.LoadFromText(a
Note that LoadFromText expects the incoming file to be in a specific format, so be aware of that.
ASKER
Hi, unfortunately it isn't static, which is why i dont want to keep deleting and importing .BAS files to the main system.
I'm going to give the Application.LoadFromText function a try in the morning - that might work.
I'll keep you posted and come back to you.
Thanks as always.
I'm going to give the Application.LoadFromText function a try in the morning - that might work.
I'll keep you posted and come back to you.
Thanks as always.
From the host database, you can use the DoCmd.TransferDatabase method ...
Public Sub FooBar(strModule As String, strDestinationDB As String)
DoCmd.TransferDatabase acExport, "Microsoft Access", strDestinationDB, _
acModule, strModule, strModule
End Sub
Public Sub FooBar(strModule As String, strDestinationDB As String)
DoCmd.TransferDatabase acExport, "Microsoft Access", strDestinationDB, _
acModule, strModule, strModule
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This solution worked beautifully.
Nice work everyone - thank you.
Nice work everyone - thank you.