I have a form, with just two buttons, say "Tyre" and "Engine". These buttons open the same form, say frmCar.
What I want to do is when I click the "Tyre" button, a tbo in the frmCar to get as value "Tyre" and when I click the "Engine" button, the same tbo in the frmCar to get the value "Engine".
The OP has asked me to take a look at this thread and advice if I can.
I think the advice given by JHB in post #2 is sound. The correct syntax for the Tyre button would be:
Code:
Private Sub Tyre_Click()
DoCmd.OpenForm "frmCars",,,,,"Tyre"
End Sub
The correct syntax for the Engine button would probably be:
Code:
Private Sub Engine_Click()
DoCmd.OpenForm "frmCars",,,,,"Engine"
End Sub
You then need to put some code in the On Open event of frmCars which would examine its own OpenArgs property. If the value is not null then assign the OpenArgs value to a control on the form.
Just wondering what exactly you want to do once frmCars has opened though.
Are you intending to enter a new record or edit an existing record.
The OP has asked me to take a look at this thread and advice if I can.
I think the advice given by JHB in post #2 is sound. The correct syntax for the Tyre button would be:
Code:
Private Sub Tyre_Click()
DoCmd.OpenForm "frmCars",,,,,"Tyre"
End Sub
The correct syntax for the Engine button would probably be:
Code:
Private Sub Engine_Click()
DoCmd.OpenForm "frmCars",,,,,"Engine"
End Sub
You then need to put some code in the On Open event of frmCars which would examine its own OpenArgs property. If the value is not null then assign the OpenArgs value to a control on the form.
Just wondering what exactly you want to do once frmCars has opened though.
Are you intending to enter a new record or edit an existing record.
In frmCars there is tbo1, which is unbound. In tbo1 I want a value to get assigned according to which button was previously pressed (in another form) in order to open frmCars.
My goal is, then, to have another tbo in frmCars, say tbo2, to check: if tbo1="Tyre" then Me.tbo2.ControlSource = a field from a query.
Respectively, if tbo1="Engine" (meaning, if "Engine" button was pressed to get to frmCars), then tbo2 should get a value from another field of the query that is the source of the frmCars.
This way, I guess, I won't need to have 2 separate forms, one to load Tyre details and one to load Engine details, according to which button was pressed.
Hope it's clear. Just to say that the tbo1 button in frmCars is unbound. I don't want to lookup for "tyre" value. I want to assign this value, or "Engine" value, to tbo1, according to which button was pressed.
You saved me once Bob, hope this will be the second and the last one!
I don't think you need these text boxes if they are just used to determine which field should be used as the Control Source of a text box. You could just examine the "OpenArgs" property in the forms On Open event as I mentioned earlier and change the Control Source property of a tbo then.
Of course, I should have realized that tbo would be your abbreviation for "text box". I don't think you need these text boxes if they are just used to determine which field should be used as the Control Source of a text box. You could just examine the "OpenArgs" property in the forms On Open event as I mentioned earlier and change the Control Source property of a tbo then.