Passing Variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please Help. I'm trying to pass the following variables bookingDate and
bookingPeriod to the function OpenBooking. It works when i pass only Ctl1,
but not when it is like this:

Private Sub Ctl1_Click()
Dim bookingDate As Date
Dim bookingPeriod As String
bookingDate = Me!date
bookingPeriod = Me!period
OpenBooking(Ctl1,bookingDate,bookingPeriod)
End Sub

Have I got the syntax wrong?

Olly Bowman
 
Thanks, Here it is.

Private Function OpenBooking(reference As Integer,bookingDate As
Date,bookingPeriod As String)

Select Case reference
Case 0
If isOpen("booking") Then
DoCmd.Close acForm, "booking"
End If
DoCmd.OpenForm "booking", , , , acFormAdd
Forms![Booking]![date] = bookingDate
Forms![Booking]![period] = bookingPeriod
Case Is > 0
DoCmd.OpenForm "booking", , , "[booking_ref]= " & reference & "
AND [date] = " & bookingDate & " AND [period] = " & bookingPeriod
Case -1
MsgBox ("Instructor is booked off")
Case -2
MsgBox ("Instructor is ill")
End Select
End Function
 
OpenBooking(Ctl1,bookingDate,bookingPeriod)

If OpenBooking is a sub, then the brackets are incorrect:

OpenBooking ctl1, bookingDate, bookingPeriod

will work.

HTH


Tim F
 
Back
Top