Passing Variables

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
 
G

Guest

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
 
T

Tim Ferguson

OpenBooking(Ctl1,bookingDate,bookingPeriod)

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

OpenBooking ctl1, bookingDate, bookingPeriod

will work.

HTH


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top