Passing variables from one form to another

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that is in modal mode and it prompts the user to pick the date
using the date time picker control.
I want to exit from this modal form and go back to the main form, but I cant
see to figure out how to pass the date that the user picked back to the main
form.
Any ideas?
 
cityofgp said:
I have a form that is in modal mode and it prompts the user to pick the date
using the date time picker control.
I want to exit from this modal form and go back to the main form, but I cant
see to figure out how to pass the date that the user picked back to the main
form.
Any ideas?

Yessm. Open your modal form using WindowMode:=acDialog, which will cause
the code to stop executing while it waits for the modal form to be closed
or, crucially, hidden. Then, when the modal form is done, instead of having
it close, make it invisible (Me.Visible = False). The code in your main
form will now start running again, whereupon it can pluck the required
values out of the hidden modal form, and then close it.
 
Hi,
Assuming frm01 is the parent form, frm02 is the child form.
You click on btn01 to display frm02 and you click on btnSave to save and
close the frm02.

Step 1:
Drag a label or Textbox control inside frm01.
Give it a name txt01
Set txt01.visible=False.

Step2:
Create an Event Procedure for btn01 in frm01:-
Private sub btn01_Click()
'initialize txt01 to some dummy value
txt01="-1"
DoCmd.OpenForm "frm02",,,,,acDialog
if (txt01<> "-1") then
'Do something with the value return
endif
end sub

Step 3:
Create an Event Procedure for btnSave in frm02 :-
Private sub btnSave_Click()
'Check if condition is true then update the txt01 in frm01
if (condition = true) then
Forms!frm01.txt01 = "200"
endif
DoCmd.Close acForm, "frm02"
end sub

Hope this help.




Let say Inside frm01 presumeably you
 
Back
Top