Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open external DB go to record

Status
Not open for further replies.

trevorwilliams2

Programmer
Mar 3, 2003
107
US
I am trying to find a way to open another access application from within another. (Shell?) I also need to find a way to tell the opening db which form to open and what record to go to.

I cant seem to find a solid way to do this.

Does anybody have any ideas on this?

Thanks!
 
You can use this code to open a form in an external database.

I found that I had to add a line of code to make the database visible.
...
.DoCmd.OpenForm strForm, intView
.Visible = True
...

Once you established an automation object you can manipulate this form like any other form
dim newFrm as access.form
....
.DoCmd.OpenForm strForm, intView
set newFrm = forms(strForm)
...
now you can manipulate the reference to newFrm
newFrm.Recorset.findFirst "someField = " & someValue
 
Also, do you need the user to see the form and work with the form or do you just need to pull in the data? There are simpler solutions if you just want the data. Also if you need to work with the form why not import the form into your database and link to the necessary tables in the other database? Although the above code does what is asked for, I do not really see the logic of doing that. I can not think of a good situation where anyone would want to do this, when I could just pull in the form and link to the other database tables.
Maybe I am missing it, and someone can suggest a case where opening a remote database form makes sense as an interface.
 
It turns out this (below) worked out pretty good for my needs. It allows me to go right to the needed form, set focus on the correct tab and load the data I need.

Private Sub CommandGoTo_Click()
Dim ProjDB As New Access.Application
DoCmd.SetWarnings False
Set ProjDB = GetObject("C:\Documents And Settings\" & fOSUserName & "\AccData\AD_COLLAGE_CLIENT.mdb")
ProjDB.DoCmd.Close acForm, "ART_MENU"
ProjDB.DoCmd.OpenForm "PROJECTS"
ProjDB.Forms!PROJECTS!FindProjCode = "AA000"
ProjDB.Forms!PROJECTS!ComboSelectProject = "AA000"
ProjDB.Forms!PROJECTS.Requery
ProjDB.Forms!PROJECTS!Minutes.Pages(1).SetFocus
DoCmd.SetWarnings True
Set ProjDB = Nothing
End Sub
 
Spoke too quick. :)

I added in the following to set focus on a field and find a record in a subform on a tab control.

ProjDB.Forms!PROJECTS!PROJECTS_SUBMITTALS!SubNumber.SetFocus
ProjDB.DoCmd.FindRecord 16, acEntire

This works great when you step though it, but on a normal execute of the routine the find record portion fails.

Maybe the subform isnt fully loaded?

 
What about this ?
ProjDB.Forms!PROJECTS!PROJECTS_SUBMITTALS.SetFocus
ProjDB.Forms!PROJECTS!PROJECTS_SUBMITTALS.Form!SubNumber.SetFocus
ProjDB.DoCmd.FindRecord 16, acEntire

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top