Callback function

  • Thread starter Thread starter Jorge Ribeiro
  • Start date Start date
J

Jorge Ribeiro

Hello

I've a form that has a button. When I click that button I want to open
another form
in dialog mode to some user data input.
After that the user clicks close on that dialog form and i need to refresh
the main
form.

Is there any callback funcionality in access that i can use to overcome this?
What do you sugest?!

best regards

Jorge
 
What I do is to set the dialog form's visible property to false and then use
code in the calling form to grab the values I want. Then I close the form in
the calling code.

I usually use two buttons on the dialog form (Ok and Cancel) and the OK button
hides the form (Visible = False) while the Cancel button closes the form.
Then in the calling code I check to see if the form is open and decide what to
do from that point.

docmd.OpenForm "DialogForm",windowmode:=acDialog
'Code paused while DialogForm is open and visible

IF CurrentProject.AllForms("DialogForm").IsLoaded = True Then
Var1 = Forms!DialogForm!FirstControl
Var1 = Forms!DialogForm!SecondControl
DoCmd.Close AcForm, "DialogForm"
'Do whatever
Else
'Do something else
End if



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
Jorge Ribeiro said:
Hello

I've a form that has a button. When I click that button I want to open
another form
in dialog mode to some user data input.
After that the user clicks close on that dialog form and i need to refresh
the main
form.

Is there any callback funcionality in access that i can use to overcome
this?
What do you sugest?!


If you open the other form in dialog mode, by specifying that argument in
your call to the OpenForm method, then code executing on the main form will
simply wait until the dialog form is closed. So you can do something
similar to this:

DoCmd.OpenForm "YourDialogForm", WindowMode:=acDialog

' Code execution pauses until YourDialogForm is closed or hidden.

Me.Refresh ' or Me.Requery, depending on your needs

I used "Me.Refresh" because you said "refresh", but often it is really
"Me.Requery" that is wanted in situations like this. "Refresh" will
retrieve updated information for all records currently displayed on the
form, but will not bring back any new records that may have been added by
the dialog form. "Requery" will rerun the form's recordsource query, so any
newly added records *will* appear. However, that will also reposition the
form to the first record, so if you want to stay on the same record as
before the Requery, you have to save that record's primary key beforehand
and relocate it afterward.
 
that was easy!

tanks Dirk

(shame on me!)

Dirk Goldgar said:
If you open the other form in dialog mode, by specifying that argument in
your call to the OpenForm method, then code executing on the main form will
simply wait until the dialog form is closed. So you can do something
similar to this:

DoCmd.OpenForm "YourDialogForm", WindowMode:=acDialog

' Code execution pauses until YourDialogForm is closed or hidden.

Me.Refresh ' or Me.Requery, depending on your needs

I used "Me.Refresh" because you said "refresh", but often it is really
"Me.Requery" that is wanted in situations like this. "Refresh" will
retrieve updated information for all records currently displayed on the
form, but will not bring back any new records that may have been added by
the dialog form. "Requery" will rerun the form's recordsource query, so any
newly added records *will* appear. However, that will also reposition the
form to the first record, so if you want to stay on the same record as
before the Requery, you have to save that record's primary key beforehand
and relocate it afterward.

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

(please reply to the newsgroup)
 
Back
Top