Re: Requery

Tech-Archive recommends: Fix windows errors by optimizing your registry



"aMack" <aMack@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:D7E3B0EF-29C7-4830-9052-9D7103FE9F72@xxxxxxxxxxxxxxxx
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.
--
A MACKENZIE, CMA, MBA


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


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

.



Relevant Pages

  • Re: How to change the form the switchboard launches ?
    ... Having said that, if you go to Database Tools / Switchboard Manager, then ... that opens the form you are referring to. ... Private Sub Form_Open ... Const conCmdGotoSwitchboard = 1 ...
    (microsoft.public.access.forms)
  • RE: Combo box parameter report
    ... open, in which case it opens the form, passing the report's name to it as its ... the report is then opened from a button on the form. ... The code for the report's Open event procedure is: ... Private Sub Report_Open ...
    (microsoft.public.access.queries)
  • Re: How does Access remind you if you want to save the changes mad
    ... Access opens the code window. ... do I add the BeforeUpdate event procedure into a form? ... If you want confirmation to save each record, use a form - in Datasheet ... Private Sub Form_BeforeUpdate ...
    (microsoft.public.access.formscoding)
  • Prompt for Parameter Value Help
    ... I created a switchboard that opens to screen where user selects name from a ... Private Sub JobNumber_Click ... already spent considerable amount of time searching tables, queries, etc. and ...
    (microsoft.public.access.forms)
  • Re: opening forms to a blank record in Access 97
    ... Add this code the the Event Procedure for the form's Load event: ... Private Sub Form_Load ... RunCommand acCmdRecordsGotoNew ... Currently, if I set the Data Entry to yes, when I open the form it opens to a ...
    (microsoft.public.access.forms)