Hi I have a Function which scrolls through my database forms Edit Reservations and looks for records which match the date entered into variable rdate. Once found its supposed to open the report "Invoices For Month End Emailing" and pass the rdate1 variable and the ReservationID variable in a WHERE clause. I can get all to work up to the point of 1 condition ie look for the Reservation ID's however it will not pass the rdate1 variable into the report. The report still asks for that variable to be typed in each time. I looked into Public variables and seperate functions etc but nothing works with 2 variables. Please help if you can :
Code:
Option Compare Database
Function Send_Monthly_Invoices()
Dim r As DAO.Recordset
Dim rdate1 As Variant
Dim rdate As Date
Dim strCondition1 As Variant
Dim strCondition2 As Variant
Dim strCondition3 As Variant
rdate = InputBox("Enter Date")
DoCmd.OpenForm "Edit Reservations", acNormal, "", "", , acNormal
Set r = Forms![Edit Reservations].RecordsetClone
r.MoveFirst
If r.RecordCount > 0 Then
Do While Not r.EOF
Set rdate1 = Forms![Edit Reservations]![Accounts subform]![Date]
Set strCondition1 = Forms![Edit Reservations]![ReservationID] = Reports![Invoices For Month End Emailing]![Reservations.ReservationID]
Set strCondition2 = Forms![Edit Reservations]![Accounts subform]![Date] = rdate1
Set strCondition3 = Forms![Edit Reservations]![ReservationID] = Reports![Reservations Letters]![Reservations.ReservationID]
If rdate = rdate1 Then
DoCmd.OpenReport "Invoices For Month End Emailing", acViewNormal, , strCondition1 And strCondition2
DoCmd.OpenReport "Booking Confirmation", acViewNormal, , strCondition3
Beep
MsgBox "Please Wait For PDF To Print Then Click Here", vbInformation, ""
DoCmd.OpenReport "Send Invoice Email", acViewNormal, "", "", acNormal
End If
DoCmd.GoToRecord , , acNext
Loop
End If
Send_Monthly_Invoices_Exit:
Exit Function
Send_Monthly_Invoices_Err:
MsgBox Error$
Resume Send_Monthly_Invoices_Exit
End Function