R
Robert
The following procedure is working fairly well, but I
can't figure out how to generate the report I need. The
code is as follows:
Public Sub FindRecord(strDate As String)
'The procedure creates a static recordset on the
tblRequisition table,
'moves to the beginning of the recordset, and uses the
Find method to
'find the first requisition with an expired rental
item that you specify
' when you call the procedure
Dim rst As New ADODB.Recordset
Dim cnn As ADODB.Connection
Dim varFound As Variant, strCriteria As String
Set cnn = CurrentProject.Connection
rst.Open "tblRequisition", cnn, adOpenStatic,
adCmdTable
strDate = Date + 5
strCriteria = "ReqDate <= '" & strDate & "'"
rst.Find strCriteria
'Find the first expired rental item in the recordset
If Not rst.EOF Then
varFound = rst.Bookmark
rst.Find strCriteria, 1
If rst.EOF Then
rst.Bookmark = varFound
MsgBox "You have requisitions with rental
items that have " _
& "expired or will be expiring soon! " & _
vbCrLf & "One example is requisition
number: " & rst!RequisitionNumber & _
vbCrLf & "The requisition date is: " & rst!
ReqDate & _
vbCrLf & "Do you want to print a rental" _
& " report now?", vbYesNo + vbCritical
vbYes = DoCmd.OpenReport [Rental Report]
'Find the second expired rental items in the recordset
Else
MsgBox "You have MULTIPLE requisitions with
rental items that have " _
& "expired or will be expiring soon! " & _
vbCrLf & "One example is requisition
number: " & rst!RequisitionNumber & _
vbCrLf & "The requisition date is: " & rst!
ReqDate & _
vbCrLf & "Do you want to print a rental" _
& " report now?"
End If
rst.Close
'Find no expired rental items in the recordset
Else
MsgBox "There are no requisitions with rental
items that will" _
& " be expiring in the next 5 days."
rst.Close
End If
End Sub
The line in question is:
vbYes = DoCmd.OpenReport [Rental Report]
When the procedure is run, I get the syntax error and not
sure how to proceed. Any help is greatly appreciated and I
thank you in advance.
can't figure out how to generate the report I need. The
code is as follows:
Public Sub FindRecord(strDate As String)
'The procedure creates a static recordset on the
tblRequisition table,
'moves to the beginning of the recordset, and uses the
Find method to
'find the first requisition with an expired rental
item that you specify
' when you call the procedure
Dim rst As New ADODB.Recordset
Dim cnn As ADODB.Connection
Dim varFound As Variant, strCriteria As String
Set cnn = CurrentProject.Connection
rst.Open "tblRequisition", cnn, adOpenStatic,
adCmdTable
strDate = Date + 5
strCriteria = "ReqDate <= '" & strDate & "'"
rst.Find strCriteria
'Find the first expired rental item in the recordset
If Not rst.EOF Then
varFound = rst.Bookmark
rst.Find strCriteria, 1
If rst.EOF Then
rst.Bookmark = varFound
MsgBox "You have requisitions with rental
items that have " _
& "expired or will be expiring soon! " & _
vbCrLf & "One example is requisition
number: " & rst!RequisitionNumber & _
vbCrLf & "The requisition date is: " & rst!
ReqDate & _
vbCrLf & "Do you want to print a rental" _
& " report now?", vbYesNo + vbCritical
vbYes = DoCmd.OpenReport [Rental Report]
'Find the second expired rental items in the recordset
Else
MsgBox "You have MULTIPLE requisitions with
rental items that have " _
& "expired or will be expiring soon! " & _
vbCrLf & "One example is requisition
number: " & rst!RequisitionNumber & _
vbCrLf & "The requisition date is: " & rst!
ReqDate & _
vbCrLf & "Do you want to print a rental" _
& " report now?"
End If
rst.Close
'Find no expired rental items in the recordset
Else
MsgBox "There are no requisitions with rental
items that will" _
& " be expiring in the next 5 days."
rst.Close
End If
End Sub
The line in question is:
vbYes = DoCmd.OpenReport [Rental Report]
When the procedure is run, I get the syntax error and not
sure how to proceed. Any help is greatly appreciated and I
thank you in advance.