We would like to run a form that will have 2 buttons that use the same report but have different results:
Button 1 - open report for current record (which we have working) using
Private Sub Command25_Click()
DoCmd.OpenReport "Bale Spike Certificate", acViewPreview, , "[no] = " & Me.[no]
End Sub
Button 2 - open (Bale Spike Certificate) report (same report that button 1 points to) but when it opens it requests the user to enter the serial number [no] which will show the report of the entered serial number.
Can get the report to work off a query by using a criteria on the [no] field, but when I change the report to use the query as the record source, button 1 (current record print) stops working and the other way round, if I use DoCmd for the current record.
Is there a way of achieving this? Or do I create 2 reports for each button?
CodePudding user response:
You could use an InputBox:
Private Sub Button2_Click()
Dim SerialNo As Long
SerialNo = Val(InputBox("Enter Serial No.:", "Bale Spike Certificate"))
If SerialNo > 0 Then
DoCmd.OpenReport "Bale Spike Certificate", acViewPreview, , "[no] = " & SerialNo & ""
End If
End Sub