Where to put the requery?

G

Guest

I have a subform1 that queries projects and supporting data from
various tables. There are 3 text boxes on subform 1 which
are used for a subform2 query to obtain additional information for
a particular project.

The fields on the subform2 are currently text boxes displaying the
results from the subform2 query and need to be converted to
combo boxes. What they will display is based on what is in the 3
text boxes of subform1. They will be used when entering new records
and will reflect the choices made in subform1.

The comboboxes need to be refreshed with each new record displayed in
subform1. I've tried putting a requery several places to no avail.
Does the requery need to be on the subform1 property Afterupdate:

This didn't work:
Private Sub Form_AfterUpdate()
Me!QueryLettersForm.cboResponseType.Requery
Me!QueryLettersForm.cboDELIVERY_TYPE.Requery
End Sub

Or on the textboxes of subform1 for each of the new comboboxes
going on subform2?

I've reviewed and tried the reomendations on
http://www.mvps.org/access/forms/frm0031.ht to no avail. I'm
obvousily missing something and need help to discover what
I'm doing incorrectly.

Thanks for your help!
 
C

Conan Kelly

I have a form with a Category ID combo box and a Sub Category ID combo box.
The choices that show up in the Sub Category ID combo box depend on what is
selected in the Category ID combo box. I put the code to requery the Sub
Category ID in the LostFocus event of the Category ID combo box:

Private Sub cboCategoryID_LostFocus()
requery_cboSubCategoryID
End Sub

Private Sub requery_cboSubCategoryID()
If IsNull(cboCategoryID) Then
Exit Sub
Else
mintCategoryID = CInt(cboCategoryID)
End If
Me!cboSubCategoryID.RowSource = "SELECT tblSubCategory.SubCategoryID,
tblSubCategory.SubCategory FROM tblSubCategory WHERE _
(((tblSubCategory.CategoryID)=" & mintCategoryID & "));"
Forms![frmProducts]![cboSubCategoryID].Requery
End Sub

Private Sub Form_Current()
requery_cboSubCategoryID
End Sub


I also put the requery in the Current event of the Form

I hope this helps.
 

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