where to put DoCmd.Close to trigger event properly

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

Guest

I have a form, which allows the user to select an option which then loads
appropriate information into a data entry form with a new record, into which
the selected value is passed. passing the value to the second form works
fine, and is triggered by a button click event. my problem is closing the
first form, which remains in the background. so far, i've tried putting it
in the following events for form #2: On Open, Before Insert, After Insert -
noe of these work, because the value from being passed (error says that event
refers to object missing). I've also tried putting the statement DoCmd.Close
acForm, Me.Name into the button click event code - that doesn't work either.

this is the code for form #1:

DoCmd.OpenForm stDocName, acNormal
DoCmd.GoToRecord , , acNewRec
Forms![Chart Review Form]!T1_Code = Me.SelectPOS
 
Try using te same code

DoCmd.OpenForm stDocName, acNormal
DoCmd.GoToRecord , , acNewRec
Forms![Chart Review Form]!T1_Code = Me.SelectPOS
docmd.Close acForm ,"Form1Name"
 
thanks, that works!! (i thought i had tried that before, but now it works, so
i won't complain ;-) )


Ofer said:
Try using te same code

DoCmd.OpenForm stDocName, acNormal
DoCmd.GoToRecord , , acNewRec
Forms![Chart Review Form]!T1_Code = Me.SelectPOS
docmd.Close acForm ,"Form1Name"

--
\\// Live Long and Prosper \\//
BS"D


janaki said:
I have a form, which allows the user to select an option which then loads
appropriate information into a data entry form with a new record, into which
the selected value is passed. passing the value to the second form works
fine, and is triggered by a button click event. my problem is closing the
first form, which remains in the background. so far, i've tried putting it
in the following events for form #2: On Open, Before Insert, After Insert -
noe of these work, because the value from being passed (error says that event
refers to object missing). I've also tried putting the statement DoCmd.Close
acForm, Me.Name into the button click event code - that doesn't work either.

this is the code for form #1:

DoCmd.OpenForm stDocName, acNormal
DoCmd.GoToRecord , , acNewRec
Forms![Chart Review Form]!T1_Code = Me.SelectPOS
 
It could be that you used the DoCmd.Close and it closed form2 that got the
focus and not form1.
This is why I used the code to specify which form to close


--
\\// Live Long and Prosper \\//
BS"D


janaki said:
thanks, that works!! (i thought i had tried that before, but now it works, so
i won't complain ;-) )


Ofer said:
Try using te same code

DoCmd.OpenForm stDocName, acNormal
DoCmd.GoToRecord , , acNewRec
Forms![Chart Review Form]!T1_Code = Me.SelectPOS
docmd.Close acForm ,"Form1Name"

--
\\// Live Long and Prosper \\//
BS"D


janaki said:
I have a form, which allows the user to select an option which then loads
appropriate information into a data entry form with a new record, into which
the selected value is passed. passing the value to the second form works
fine, and is triggered by a button click event. my problem is closing the
first form, which remains in the background. so far, i've tried putting it
in the following events for form #2: On Open, Before Insert, After Insert -
noe of these work, because the value from being passed (error says that event
refers to object missing). I've also tried putting the statement DoCmd.Close
acForm, Me.Name into the button click event code - that doesn't work either.

this is the code for form #1:

DoCmd.OpenForm stDocName, acNormal
DoCmd.GoToRecord , , acNewRec
Forms![Chart Review Form]!T1_Code = Me.SelectPOS
 
Back
Top