Requery Help !!!

zacharyjunior

Registered User.
Local time
Today, 22:30
Joined
Jan 11, 2002
Messages
26
I have a customer table that lets us put in a new customer while in the complaint form. After the new customer is entered I tried to locate the customer in the drop down box but they did not appear. I had to close out of all the forms and go back in in order for ut to show up. I believe that you would need to requery the customer query but how? Please detail. I have not used VB that much yet and need to know how to do it!!

Thanks
 
In the code module that adds the new customer add the following line at the very end of the code:

ComboboxName.Requery

That should give you the newly added customer.
 
The simpliest was is to actually requery the combo that has the customer name - so after you save the customer, you then do cboCustomer.Requery. If the Row Source property of the combo box does not have the query and you do the query seperately, you will have to run over your query and then refresh the combo box.
 
Are you using a button to update the record or just entering it straight into the table?
If you are entering it straight, you may want to add a button anyway in order to execute a refresh of the forms. To do this, simply add a button to the form and select refresh form in the button wizard.
 
It is not clear where the new customer is added. It sounds like it might be on the complaint form. Is this a separate form from where the customer combo box is located? If so, if the form holding the customer combo is ALWAYS open when the complaint form is open you can requery the customer combo from the complaint form.

If that is the case, open the complaint form. At the upper left of your screen under the word "File" there is a little triangle icon, click on it, this will take you to design mode of that form. Then again at the top of the screen near the middle is another icon with red, blue and yellow dots on it (hold your cursor over it and it will say "Code"), click on it and you will bring up the code module for that form. If you are totally lost at this point, get somone to help you. If not, find the spot in the code where you need to insert your combobox.Requery.

Good Luck.
 
Here is the code. Where should I enter the requery command?
Private Sub Disposition_Click()
Me.Visible = False
DoCmd.OpenForm "frmDisposition"

End Sub

Private Sub Form_Current()
Me.Address = Me.Combo59.Column(2)
Me.City = Me.Combo59.Column(3)
Me.State = Me.Combo59.Column(4)
Me.Zip = Me.Combo59.Column(5)
Me.Phone = Me.Combo59.Column(6)
End Sub
Private Sub cmdNewCustomerButton_Click()
On Error GoTo Err_cmdNewCustomerButton_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCustomers"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdNewCustomerButton_Click:
Exit Sub

Err_cmdNewCustomerButton_Click:
MsgBox Err.Description
Resume Exit_cmdNewCustomerButton_Click

End Sub
Private Sub cmdCopyRecord_Click()
On Error GoTo Err_cmdCopyRecord_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_cmdCopyRecord_Click:
Exit Sub

Err_cmdCopyRecord_Click:
MsgBox Err.Description
Resume Exit_cmdCopyRecord_Click

End Sub
 
If my assumption is correct - you save the new customer in the CopyRecord - so after, just before the end of the Sub, you can Combo59.Reqyery
 

Users who are viewing this thread

Back
Top Bottom