By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,917 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,917 IT Pros & Developers. It's quick & easy.

MS Access Import Forms from another mdb

P: 8
Is there a simple way to import all forms from another mdb into the currently open mdb? I have trouble getting the current code to "see" a "forms" object in the external mdb.
Apr 25 '07 #1
Share this Question
Share on Google+
10 Replies


pks00
Expert 100+
P: 280
did u try File/Get External Data/Import ?
Apr 26 '07 #2

NeoPa
Expert Mod 15k+
P: 31,492
For all forms (especially when there are many) the Import method is best. For an individual form, it is possible to use simply Copy/Paste as long as both databases are open.
Apr 26 '07 #3

P: 8
did u try File/Get External Data/Import ?
That works great but I would like to be able to do this using VBA code.
In trying this, I have problems setting up the foreign "Forms" object to cycle through. Any Ideas?
Apr 30 '07 #4

NeoPa
Expert Mod 15k+
P: 31,492
Forms is an attribute of the Application object and is NOT what contains the objects to be imported.
The Forms collection contains only open forms in the currently open database.
Apr 30 '07 #5

P: 8
Forms is an attribute of the Application object and is NOT what contains the objects to be imported.
The Forms collection contains only open forms in the currently open database.
I would like to do this in VBA because there seems to be a hole in my understanding of the "Forms" identity. If I View the objects, I can see what appears to be a "Forms" object but I could not create or "cast" the Application.CurrentProject.Allforms (object/container) into a Forms object. I seem to have a blind spot here. Is there a good source where I might get an understanding of this.
May 1 '07 #6

P: 2
Hi

I am trying to do exactly the same thing. Have you found a way yet?


I would like to do this in VBA because there seems to be a hole in my understanding of the "Forms" identity. If I View the objects, I can see what appears to be a "Forms" object but I could not create or "cast" the Application.CurrentProject.Allforms (object/container) into a Forms object. I seem to have a blind spot here. Is there a good source where I might get an understanding of this.
May 10 '07 #7

NeoPa
Expert Mod 15k+
P: 31,492
I would like to do this in VBA because there seems to be a hole in my understanding of the "Forms" identity. If I View the objects, I can see what appears to be a "Forms" object but I could not create or "cast" the Application.CurrentProject.Allforms (object/container) into a Forms object. I seem to have a blind spot here. Is there a good source where I might get an understanding of this.
There probably is, but I'm not that good on external references.
Application.CurrentProject.AllForms is a Collection object. The object 'contains' form objects but is not, itself, a Form object. Does that throw any light on the problem?
May 10 '07 #8

NeoPa
Expert Mod 15k+
P: 31,492
Hi

I am trying to do exactly the same thing. Have you found a way yet?
Joel,
You can see the same as we can what's in here.
Your choices are to :
  1. Follow this thread (you're already subscribed now).
    You can contribute too if that will help.
  2. Create a new thread of your own with a well phrased question.
Please don't though, divert the course of this thread for your own purposes (Don't worry - you haven't done so far) as that can cause confusion and irritation for all concerned.

MODERATOR.
May 10 '07 #9

P: 2
Hi

I've managed to do it like this:

Expand|Select|Wrap|Line Numbers
  1. Dim appAccess As Access.Application
  2. Dim fileNameStr As String
  3. Dim frmSearch As Variant
  4.  
  5. ' this is the file you are importing from
  6. fileNameStr = "C:\My Documents\Update1.mdb"
  7.  
  8. Set appAccess = New Access.Application
  9. appAccess.OpenCurrentDatabase fileNameStr
  10.  
  11. For Each frmSearch In appAccess.CurrentProject.AllForms
  12.  
  13. 'transfer each form - use the same name
  14. DoCmd.TransferDatabase acImport, "Microsoft Access", fileNameStr, acForm, frmSearch.Name, frmSearch.Name
  15.  
  16. ' for testing
  17. Debug.Print frmSearch.Name
  18.  
  19. Next frmSearch
  20.  
  21. appAccess.CloseCurrentDatabase
  22. Set appAccess = Nothing


Hope this helps

Joel


Hi

I am trying to do exactly the same thing. Have you found a way yet?
May 10 '07 #10

NeoPa
Expert Mod 15k+
P: 31,492
Hi

I've managed to do it like this:

Expand|Select|Wrap|Line Numbers
  1. Dim appAccess As Access.Application
  2. Dim fileNameStr As String
  3. Dim frmSearch As Variant
  4.  
  5. ' this is the file you are importing from
  6. fileNameStr = "C:\My Documents\Update1.mdb"
  7.  
  8. Set appAccess = New Access.Application
  9. appAccess.OpenCurrentDatabase fileNameStr
  10.  
  11. For Each frmSearch In appAccess.CurrentProject.AllForms
  12.  
  13. 'transfer each form - use the same name
  14. DoCmd.TransferDatabase acImport, "Microsoft Access", fileNameStr, acForm, frmSearch.Name, frmSearch.Name
  15.  
  16. ' for testing
  17. Debug.Print frmSearch.Name
  18.  
  19. Next frmSearch
  20.  
  21. appAccess.CloseCurrentDatabase
  22. Set appAccess = Nothing


Hope this helps

Joel
Nice solution Joel :)
It uses Application Automation too.
We always appreciate when members post answers after finding them, so well done on that score too.

BTW Within Access, the object Application would be equivalent (and predefined) for what you set up in appAccess.
May 10 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.