Open the same form but change properties

bunji

Registered User.
Local time
Today, 08:59
Joined
Apr 26, 2005
Messages
124
I have a standard form but i would like it so that when a user clicks on the button from the main menu to open the form it changes the default view which i have set to data entry and change it to not data entry. Also another button to change its record source to a different query. Rather than make lots of different forms that have the same thing but for just different purposes.

I hope that makes sense?

Thanks
 
Consider using the OpenArgs argument when you open the form.

From frmMainMenu, I open frmTest this way...

DoCmd.OpenForm FormName:="frmTest", OpenArgs:="MM"

From frmOther, I open it this way...

DoCmd.OpenForm FormName:="frmTest", OpenArgs:="Other"

Within the frmTest I code the Form_Load procedure and test the Me.OpenArgs. Based on the value, I change the Form's RecordSource and Requery.
 
This is a several-step process.

This is what I would do (haven't tried it):
Click on button1 to open Form1, set Data Entry to No and set Record Source to query1
Click on button2 to open Form1, set Data Entry to Yes and set Record Source to query2.

Code:
Private Sub button1_OnClick()
     OpenForm1 False "query1"
End Sub

Private Sub button2_OnClick()
     OpenForm1 True "query2"
End Sub

Function OpenForm1 (DataEntrySet As Boolean, RecSource As String)
     DoCmd.OpenForm "Form1"
     Forms("Form1").DataEntry = DataEntrySet
     Forms("Form1").RecordSource = RecSource
End Function

You also might want to set those properties back to default after done.
 
Thanks supercharge i thought your way looked the simplest, tried it worked. I was dreading make up lots of other forms!
 

Users who are viewing this thread

Back
Top Bottom