Using a form multiple times

S

souchie40

I have a form that I've copied to use on several different occasions with a
different recordsource, what I would like to do is have the form once and
then on selecting from the switchboard a particular data version the query
for the recordsource is selected, first is this possible?, but the real snag
that I see is that on this form I have a command button the does a requery by
chnaging the source running a requery and then selecting the recordsource, as
this is done from within the form how would I tell it to open the right
querry for the recordsource.
 
G

Graham R Seach

Take a look at the following web page for information about setting up a
reusable form:
http://www.pacificdb.com.au/MVP/Code/MyDialog.htm

To set the form's RecordSource, create a public property procedure,
something like this:

Public Property Let FormRecordSource(ByVal sNewValue As String)
If Len(Trim(sNewValue)) > 0 Then
Me.RecordSource = sNewValue
End If
End Property

Set the RecordSource property before making the dialog visible:
Private frm As Form_MyForm
'- - -
Set frm = New Form_MyForm
frm.FormRecordSource = "SELECT * FROM Table1"
frm.Visible = True
'- - -
Set frm = Nothing

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
G

Graham R Seach

It's been a while since I developed against A97, but from memory it should
still work.

Regards,
Graham R Seach
Microsoft Access MVP
Canberra, Australia
 
Top