Requery

A

aMack

I have created an input form for new records from our main production form.

The main form does not refresh after the new record is added.

A "requery" command works when the form is opened from the Form objects menu
but not when initaited from our "Main Switchboard" form.

1) From Main Switchboard - Open form "Intermodal Transload"
2) From form "Intermodal Transload" initaite macro "Add New Order" - This
adds a new REF# to the data table Intermodal Transload and opens a form "Add
New Order".
3) Close form "Add New Record" with an "On Close" command:
Form(Intermodal_Transload).Requery

Why does this work when the form is opened from the object menu but does not
work when opened through the Main Switchboard?

Please help.
 
D

Dirk Goldgar

aMack said:
I have created an input form for new records from our main production form.

The main form does not refresh after the new record is added.

A "requery" command works when the form is opened from the Form objects
menu
but not when initaited from our "Main Switchboard" form.

1) From Main Switchboard - Open form "Intermodal Transload"
2) From form "Intermodal Transload" initaite macro "Add New Order" - This
adds a new REF# to the data table Intermodal Transload and opens a form
"Add
New Order".
3) Close form "Add New Record" with an "On Close" command:
Form(Intermodal_Transload).Requery

Why does this work when the form is opened from the object menu but does
not
work when opened through the Main Switchboard?

Please help.


I have no idea what is going on when you open the form from the object menu,
but if this:
Form(Intermodal_Transload).Requery

.... is the line of code you are executing, it ought by rights to give you an
error. Try this:

Forms!Intermodal_Transload.Requery

or this equivalent:

Forms("Intermodal_Transload").Requery

Bear in mind that a line of VBA code like that can't be placed directly in
the OnClose property of your "Add New Order" form -- it has to be in an
event procedure. The OnClose property should be set to "[Event Procedure]",
and then the event procedure would look like:

Private Sub Form_Close()

Forms!Intermodal_Transload.Requery

End Sub

Actually, I'd recormmend checking to make sure the form is open, like this:

Private Sub Form_Close()

Const conTransloadForm As String = "Intermodal_Transload"

If CurrentProject.AllForms(conTransloadForm).IsLoaded Then
Forms(conTransloadForm).Requery
End If

End Sub
 

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

Top