projecttoday
Programmer
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
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