Form properties from another database

  • Thread starter Thread starter Michael Favor
  • Start date Start date
M

Michael Favor

I can find out the record-source of a form in my current
database like this:

varSource = Forms("Form Name").RecordSource

but, I really want to find out the record-source for a
form in another database. It seems like I should be able
to do something like this, but the (???) has got me
stumped.

myContainer = OpenDatabase("otherdata.mdb").Containers
("Forms")
varSource = myContainer.(???).RecordSource


any insight would be appreciated!

regards,
michael.
 
Michael Favor said:
I can find out the record-source of a form in my current
database like this:

varSource = Forms("Form Name").RecordSource

but, I really want to find out the record-source for a
form in another database. It seems like I should be able
to do something like this, but the (???) has got me
stumped.

myContainer = OpenDatabase("otherdata.mdb").Containers
("Forms")
varSource = myContainer.(???).RecordSource

Unfortunately, the form must be open (whether in Form View or Design
View) in order for you to check its properties that way. I think you're
going to have to automate a second instance of Access in order to do
this. Something like this:

'----- start of "air" code -----
Function fncForeignFormRecordSource( _
DBPath As String, _
FormName As String) _
As String

Dim appAccess As Access.Application

Set appAccess = New Access.Application

With appAccess
.Echo False
.OpenCurrentDatabase DBPath
.DoCmd.OpenForm FormName, acDesign
fncForeignFormRecordSource = .Forms(FormName).RecordSource
.DoCmd.Close acForm, FormName, acSaveNo
.Quit
End With

Set appAccess = Nothing

End Function

'----- end of code -----
 
Back
Top