Main form closes when I requery from dialogue box.

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

Guest

Novice

I have a main form (GtTextForm) that clicks to a form/dialogue box
(UpdateForm). On UpdateForm, the button Publish has the following On Click
property Event procedure to exit the form and return to the main form
(GtTextForm).

It works fine except the Date doesn't appear in RecordPublished until I
manually Refresh the main form, but when I added
(Forms!GtTextForm.Form.Requery), the main form (GtTextForm) closes leaving
the dialoge box open.

Private Sub PublishButton_Click()
On Error GoTo Err_PublishButton_Click
Forms!GtTextForm!NextUpdateDue = Me!Combo2
Forms!GtTextForm!RecordPublished = Date
Forms!GtTextForm.Form.Requery (problem line??????????)
DoCmd.Close

Exit_PublishButton_Click:
Exit Sub

Err_PublishButton_Click:
MsgBox Err.Description
Resume Exit_PublishButton_Click

End Sub

Thank you

Peter
 
Peter,

Well, the code should be...
Forms!GtTextForm.Requery
Anyway, what's happening is the Requery method is moving the focus to
the GtTextForm form, so this is the object that the DoCmd.Close is
acting on, thus closing the form. This is one example of why I would
always specify the object to close, i.e....
DoCmd.Close acForm, Me.Name

In any case, I can't see that Requery is the correct method anyway. I
would try it like this...

Private Sub PublishButton_Click()
Forms!GtTextForm!NextUpdateDue = Me!Combo2
Forms!GtTextForm!RecordPublished = Date
DoCmd.RepaintObject acForm, "GtTextForm"
DoCmd.Close acForm, Me.Name
End Sub
 
Repaint didn't work.

Forms!GtTextForm.Requery
DoCmd.Close acForm, Me.Name

worked fine.

Thanks for taking the time Steve--you guys are so valuable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top