Im messing around trying to learn Access and have hit a problem.
I have a table called tblbookings and i want to seach though it when trying to make a new booking to make sure the room isnt alrady booked.
In tblbookings i have a room_number, booking_start_d ate and booking_end_dat e
Ive tried all sorts of code but it either brings up an error or doesnt do anything at all. Hoping someone can help.
Ive got as far as bringing up a message box if it finds the same room already in the booking table (which obviously isnt very useful but its as far as i can get!)
Im using the following code:
Can someone have a look and tell me what i should be doing. Cheers
If Me.NewRecord = True Then
Dim strWhere As String, strmessage As String
    
strWhere = "Room_Numbe r = " & Me!Room_Number
    
Me.RecordsetClo ne.MoveFirst
Me.RecordsetClo ne.FindFirst strWhere
    
Do Until Me.RecordsetClo ne.nomatch
If Me.RecordsetClo ne!Room_Numnber = Me!Room_Number Then
MsgBox ("test")
Cancel = True
Exit Sub
End If
Me.RecordsetClo ne.FindNext strWhere
Loop
End If
					I have a table called tblbookings and i want to seach though it when trying to make a new booking to make sure the room isnt alrady booked.
In tblbookings i have a room_number, booking_start_d ate and booking_end_dat e
Ive tried all sorts of code but it either brings up an error or doesnt do anything at all. Hoping someone can help.
Ive got as far as bringing up a message box if it finds the same room already in the booking table (which obviously isnt very useful but its as far as i can get!)
Im using the following code:
Can someone have a look and tell me what i should be doing. Cheers
If Me.NewRecord = True Then
Dim strWhere As String, strmessage As String
strWhere = "Room_Numbe r = " & Me!Room_Number
Me.RecordsetClo ne.MoveFirst
Me.RecordsetClo ne.FindFirst strWhere
Do Until Me.RecordsetClo ne.nomatch
If Me.RecordsetClo ne!Room_Numnber = Me!Room_Number Then
MsgBox ("test")
Cancel = True
Exit Sub
End If
Me.RecordsetClo ne.FindNext strWhere
Loop
End If
Comment