Dag Solder
New member
- Local time
- Today, 02:37
- Joined
- May 8, 2020
- Messages
- 19
Hi everyone,
I have 2 forms: Frm_A & Frm_B. Frm_A is a small pop up which contains a combo box to allow the user to select a record to be passed to Frm_B and a command button ‘EDIT’
Frm_A and Frm_B are opened by another form at the same time with Frm_B being hidden until a command button is pressed to transfer data from A to B, at this stage Frm_A is hidden and Frm_B has the record ID passed to it. This all seems to work ok. Code on command button on Frm_A:
Once this code has run, Frm_B is available to the user with the selected record displayed - great!!
I now have another set of code to run within Frm_B, ordinarily I would have run it with the ‘On Load’ Property of the Form, but in this instance I can’t as the form opens before the data has been passed from Frm_A
As a temporary fix I am running the subject code from a command button on Frm_B, it works, but this is not ideal for many reasons, not least, the button must be pressed and if it isn't the project fails.
These are the requirements:
The code must be run, it must only be run once (another reason why a button is not ideal although it could be deactivated once pressed), it must be run before any data on the form is changed (This is a big problem with the button on the form) and it cannot be run until the data from Frm_A is passed to Frm_B.
I have experimented with various methods including using some of the form properties, but nothing seems to work as intended.
Any ideas??
I am new to VBA so please be gentle
Cheers Dag.
I have 2 forms: Frm_A & Frm_B. Frm_A is a small pop up which contains a combo box to allow the user to select a record to be passed to Frm_B and a command button ‘EDIT’
Frm_A and Frm_B are opened by another form at the same time with Frm_B being hidden until a command button is pressed to transfer data from A to B, at this stage Frm_A is hidden and Frm_B has the record ID passed to it. This all seems to work ok. Code on command button on Frm_A:
Code:
Private Sub EDIT_Click()
DoCmd.OpenForm "Frm_B", acNormal, "", "", , acWindowNormal
DoCmd.OpenForm "Frm_A", acNormal, "", "", , acHidden
DoCmd.OpenForm " Frm_B", , , "[ID] = " & Me.txtZiff ' Value of txt box txtZiff=
End Sub
Once this code has run, Frm_B is available to the user with the selected record displayed - great!!
I now have another set of code to run within Frm_B, ordinarily I would have run it with the ‘On Load’ Property of the Form, but in this instance I can’t as the form opens before the data has been passed from Frm_A
As a temporary fix I am running the subject code from a command button on Frm_B, it works, but this is not ideal for many reasons, not least, the button must be pressed and if it isn't the project fails.
These are the requirements:
The code must be run, it must only be run once (another reason why a button is not ideal although it could be deactivated once pressed), it must be run before any data on the form is changed (This is a big problem with the button on the form) and it cannot be run until the data from Frm_A is passed to Frm_B.
I have experimented with various methods including using some of the form properties, but nothing seems to work as intended.
Any ideas??
I am new to VBA so please be gentle
Cheers Dag.