Solved Extract Forms/Reports/Scripts/Modules/Queries from external database

Alt

Member
Local time
Today, 18:49
Joined
Sep 6, 2021
Messages
35
Hi guys,

I'm able to import tables from an external file (each table renamed) but having en error message (see mod_ExportDocs). Can you help me to figure out plz?

Merry Christmas to everyone!
 

Attachments

  • dbobjects.png
    dbobjects.png
    15.4 KB · Views: 78
  • DBObjects_ML.zip
    DBObjects_ML.zip
    210 KB · Views: 122
On what line of code? Did you include the database you are linking to?
When you want us to debug something, you need to give us all the pieces and tell us where the error is happening.
 
On what line of code? Did you include the database you are linking to?
When you want us to debug something, you need to give us all the pieces and tell us where the error is happening.
Everything is well attached... You have the error message when you press "Export Docs" button
 
1. This is the message I get. I'm assuming it thinks some db named TestDB.accdb should be in the folder but of course, it wasn't included in the download so it isn't there. Am I supposed to create an empty database with this name?
xxxExportError.JPG


2. I created the db but of course that wasn't the problem at all. It needs to be a db with objects in it.

3. VOILA! Turns out the problem is caused by sloppy coding. EVERY module should have as its first two lines:
Code:
Option Compare Database
Option Explicit
So, start by changing the Access option to require variable declaration. Then fix the compile errors to fix your problem.
 
1. This is the message I get. I'm assuming it thinks some db named TestDB.accdb should be in the folder but of course, it wasn't included in the download so it isn't there. Am I supposed to create an empty database with this name?
View attachment 105432

2. I created the db but of course that wasn't the problem at all. It needs to be a db with objects in it.

3. VOILA! Turns out the problem is caused by sloppy coding. EVERY module should have as its first two lines:
Code:
Option Compare Database
Option Explicit
So, start by changing the Access option to require variable declaration. Then fix the compile errors to fix your problem.
you can read any external db but I've revised the zip files to include this testDB.accdb.
 
That's fine but we don't know you your app works so you might have mentioned that. Did you fix the Option Explicit since that was what hid the problem from you?
 
That's fine but we don't know you your app works so you might have mentioned that. Did you fix the Option Explicit since that was what hid the problem from you?
If you want to see my error message, press "Go" button (this will fill the form) then "Export Docs". You cna chech "mod_ExportDocs" (into VB editor)
 
Did you understand my instruction on HOW TO FIX THE ERROR? You have dim'd the database name as dbs but most of the references are to db. If you had Option Explicit turned on, you would see this because of the compile errors it causes!!
 
Did you understand my instruction on HOW TO FIX THE ERROR? You have dim'd the database name as dbs but most of the references are to db. If you had Option Explicit turned on, you would see this because of the compile errors it causes!!
yes I put those two lines in every module and I no longer have an error message (Thanks... zip file is updated)
But I'm still unable to create txt files when I hit Export Docs" (mod_ExportDocs).
 
Did you fix the compile errors? You have a variable defined with one name but you are using a different name in the rest of the code. Therefore IT DOES NOT COMPILE. Code that does not compile rarely actually works:( FIX the compile errors to fix the problem.
 
Application.SaveAsText acForm, doc.Name, sExtDbPath & Format(Date, "yyyymmdd") & doc.Name & ".txt"

SaveAsText creates text files. These are to be stored in a folder in the file system, not in an access file. Consequently, one would not use a file selection dialog here, but a directory selection dialog to generate valid paths for the export.
 
here test this one:

the reason that your code does not work is that you are using Application.SaveAsText.
the "Application" there pertains to the Currentdb's Application and not the External db's Application.
remember the Forms (or objects) you are trying to Export is in another db not in the Currentdb.

you need to Open an Access.Application, and open the external db using the New access instance.
 

Attachments

  • Like
Reactions: Alt
here test this one:

the reason that your code does not work is that you are using Application.SaveAsText.
the "Application" there pertains to the Currentdb's Application and not the External db's Application.
remember the Forms (or objects) you are trying to Export is in another db not in the Currentdb.

you need to Open an Access.Application, and open the external db using the New access instance.
working fine... Thanks a lot.
 
If it is working, I guess you fixed the compile errors.
 
arnelgp provide a solution (no mention of compile errors...)
Really?
Here are two
Code:
Private Sub Commande19_Click()
    Call ImportAllFrms(txtFilename)
End Sub

Private Sub Commande20_Click()
    Call ImportAllQrys(txtFilename)
End Sub

Functions do not exist. However there only appears to be one button now to import everything?
Any that did exist, arnel would have likely corrected anyway.
 
Really?
Here are two
Code:
Private Sub Commande19_Click()
    Call ImportAllFrms(txtFilename)
End Sub

Private Sub Commande20_Click()
    Call ImportAllQrys(txtFilename)
End Sub

Functions do not exist. However there only appears to be one button now to import everything?
Any that did exist, arnel would have likely corrected anyway.
some modules was removed because I don't have any issue with.
 

Users who are viewing this thread

Back
Top Bottom