K
Kate
I really need help here! I have a button on a form with
the code below. It doesn't work because AVAILABILITY.
[Booking ID] isn't accessible. How can I solve this
problem?
Option Compare Database
Private Sub Command14_Click()
'On Error GoTo Err_CheckAvail_Click
DoCmd.OpenQuery "QueryAv"
DoCmd.Close acQuery, "QueryAv"
If AVAILABILITY.[Booking ID] = 1 Then
' 'Close query
DoCmd.Close acQuery, "QueryAv"
' 'Hide availability form
Forms![SINGLE BOOKING AVAILABILITY].Visible = False
' 'Open the detail form
DoCmd.OpenForm "SINGLE BOOKING DETAIL"
' 'Show new form
Forms![SINGLE BOOKING DETAIL].Visible = True
' 'DoCmd.Close acForm, "SINGLE BOOKING AVAILABILITY"
End If
Exit_Command14_Click:
Exit Sub
Err_CheckAvail_Click:
MsgBox Err.Description
Resume Exit_Command14_Click
End Sub
QueryAv is:
SELECT AVAILABILITY.BookingDate, AVAILABILITY.Period,
AVAILABILITY.Room, AVAILABILITY.[Day Number], AVAILABILITY.
[Booking ID]
FROM AVAILABILITY
'WHERE (((AVAILABILITY.BookingDate)=Forms![SINGLE BOOKING
AVAILABILITY]!BookingDate) And ((AVAILABILITY.Period)
=Forms![SINGLE BOOKING AVAILABILITY]!Combo8) And
((AVAILABILITY.Room)=Forms![SINGLE BOOKING AVAILABILITY]!
Combo10));
the code below. It doesn't work because AVAILABILITY.
[Booking ID] isn't accessible. How can I solve this
problem?
Option Compare Database
Private Sub Command14_Click()
'On Error GoTo Err_CheckAvail_Click
DoCmd.OpenQuery "QueryAv"
DoCmd.Close acQuery, "QueryAv"
If AVAILABILITY.[Booking ID] = 1 Then
' 'Close query
DoCmd.Close acQuery, "QueryAv"
' 'Hide availability form
Forms![SINGLE BOOKING AVAILABILITY].Visible = False
' 'Open the detail form
DoCmd.OpenForm "SINGLE BOOKING DETAIL"
' 'Show new form
Forms![SINGLE BOOKING DETAIL].Visible = True
' 'DoCmd.Close acForm, "SINGLE BOOKING AVAILABILITY"
End If
Exit_Command14_Click:
Exit Sub
Err_CheckAvail_Click:
MsgBox Err.Description
Resume Exit_Command14_Click
End Sub
QueryAv is:
SELECT AVAILABILITY.BookingDate, AVAILABILITY.Period,
AVAILABILITY.Room, AVAILABILITY.[Day Number], AVAILABILITY.
[Booking ID]
FROM AVAILABILITY
'WHERE (((AVAILABILITY.BookingDate)=Forms![SINGLE BOOKING
AVAILABILITY]!BookingDate) And ((AVAILABILITY.Period)
=Forms![SINGLE BOOKING AVAILABILITY]!Combo8) And
((AVAILABILITY.Room)=Forms![SINGLE BOOKING AVAILABILITY]!
Combo10));