Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confused as to what to requery

Status
Not open for further replies.

projecttoday

Programmer
Feb 28, 2004
208
US
I have a form with 2 command buttons on it. One button executes some append queries. The other button creates a report from a query which reads data in part created by the first button. But when I do the buttons in succession, I don't get any data in my report. If I close the form then go back into and position it at the same record, the report works. I don't understand this because I'm opening the report and the query attached to it after finishing the table update. Does anybody know how I can correct this and make my report work without closing my form?

Robert

here is the code for the update button:

On Error GoTo Err_Command27_Click

Dim stDocName As String
Dim strmsg As String

stDocName = "qryStartRental"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acNormal, acEdit

stDocName = "qryItemOutRental"
DoCmd.OpenQuery stDocName, acNormal, acEdit

cmbItemNo.Requery
DoCmd.SetWarnings True

strmsg = "Rental has been booked for customer "
strmsg = strmsg & [Forms]![frmrentals]![fldCustNo]
strmsg = strmsg & " item " & [Forms]![frmrentals]![flditemno]
MsgBox strmsg

Exit_Command27_Click:
Exit Sub

Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click




Here is the code for the report button:

On Error GoTo Err_Command33_Click

Dim stDocName As String
Dim stCond As String
Dim icount As Integer

icount = 0
icount = DCount("[fldrentalstartdate]", "tblRentalStarts", "[fldrentalno] = [forms]![frmrentals]![fldrentalno]")
If icount > 0 Then
stDocName = "rptContract"
DoCmd.OpenReport stDocName, acPreview, , "qrycontract2.fldrentalno = [forms]![frmrentals]![fldrentalno]"
Else
MsgBox "Booking not found. Have you booked the rental yet?"
End If

Exit_Command33_Click:
Exit Sub

Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click
 
You may try to call DoEvents after each query.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
...
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoEvents
stDocName = "qryItemOutRental"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoEvents
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
BTW, is Forms!frmrentals!fldrentalno populated when you click the Report button ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I figured it out. I do
gocmd.GotoRecord
after the file update and it is working fine now. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top