Find Method

  • Thread starter Thread starter jmonty
  • Start date Start date
J

jmonty

try removing the brackets. The report name needs to be a
string.
Try it this way:

Dim stDocName As String
stDocName = "Rental Report"
DoCmd.OpenReport stDocName, acPreview
 
I inserted the following as you suggested:

Dim stDocName As String
stDocName = "Rental Report"
DoCmd.OpenReport stDocName, acPreview

But it still will not execute from the vbYes button. Any
thoughts? Or, is this a problem because of the recordset
being a static cursor recordset? Thanks again...
-----Original Message-----
try removing the brackets. The report name needs to be a
string.
Try it this way:

Dim stDocName As String
stDocName = "Rental Report"
DoCmd.OpenReport stDocName, acPreview

-----Original Message-----
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.




.
.
 
Back
Top