Requery data in cbo box on subfrm

D

Danielle

I have a form with a sub form that contains contact
information.
CboBox is set to LimitToList = yes. The user must select
a contact from the list or add a new contact by selecting
a link which opens a form to add the new contact
information. When this form(popup = yes, modal = yes) is
closed I want the cbobox on the subfrm to requery with the
new contact information that was just entered. I just
can't seem to get it to work.
Any help would be so appreciated!

Thank you,
Danielle
 
G

Guest

Try calling the pop-up form in dialog windowmode. This will suspend code in the main form until the pop-up is closed. For the next line of code in the main form, requery the combobox, like me.subform1.cb1.requery. Hope this helps

- Scot

----- Danielle wrote: ----

I have a form with a sub form that contains contact
information.
CboBox is set to LimitToList = yes. The user must select
a contact from the list or add a new contact by selecting
a link which opens a form to add the new contact
information. When this form(popup = yes, modal = yes) is
closed I want the cbobox on the subfrm to requery with the
new contact information that was just entered. I just
can't seem to get it to work
Any help would be so appreciated

Thank you
Daniell
 
J

John Smith

Put :-

Forms!FormName!SubFormControlName.Form!ComboName.Requery

in the close event of your popup form, substituting your own names for the form
and controls. Note that SubFormControlName is the name of the SubForm Control,
which is not necessarily the same as the name of the Form that is in it.
 
D

danielle

It works great. Now the only problem I have is that I
need to use this pop up form in 4 other forms. Is there
any way to make the code line universal?

Thanks again,
Danielle
 
J

John Smith

Sorry, I have only just spotted your follow-on question and realised that I had
not replied to it. If you pass the name of your form and control in the form
OpenArgs, you can use the following code in your close button to do the requery
:

Dim FormName As String
If Nz(Me.OpenArgs) <> "" Then
If InStr(Me.OpenArgs, "_") > 1 Then
FormName = Mid$(Me.OpenArgs, InStr(Me.OpenArgs, "_") + 1)
Else
FormName = Me.OpenArgs
End If
If FormName <> "" Then Eval ("Forms!" & FormName & ".Requery")
End If
FormClose

It is taken from one of my forms, and allows for a code being passed as the
first part of OpenArgs. You can omit that bit if you don't need it. OpenArgs
should be something on the lines of :

FormName!SubFormControlName.Form!ComboName
 

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