Spikemannen
Instructor
Hi!
I have tried this code in both access 2000 and access xp.
In access 2000 this works, but not in access xp?!
How should I do this to get it to work in access xp?
Problem:
I have a form where I name an object and choose between which two dates it is avaible in the form frmObject.
In my second form, frmBooking, I will choose between which two dates I want the object.
The dates has to be between the two avaible dates for the object in frmObject. When there is another persone who wants to book the object he/she shouldn't be able too book the object when I have booked it.
My code looks like this:
So what will I do? Please help me...
Best Regardz,
Spikemannen
I have tried this code in both access 2000 and access xp.
In access 2000 this works, but not in access xp?!
How should I do this to get it to work in access xp?
Problem:
I have a form where I name an object and choose between which two dates it is avaible in the form frmObject.
In my second form, frmBooking, I will choose between which two dates I want the object.
The dates has to be between the two avaible dates for the object in frmObject. When there is another persone who wants to book the object he/she shouldn't be able too book the object when I have booked it.
My code looks like this:
Code:
Private Sub txtArrival_AfterUpdate()
Dim strObject As String
Dim strFromdate As String
Dim strAvFromDate As String
Dim strAvToDate As String
Dim strBookFromDate As String
Dim strBookToDate As String
strObject = Form_frmBooking.cboObject.Value
If cboObject.Value = False Then
MsgBox "You have to choose an object.", , "Booking"
txtArrival.Value = ""
cboObject.SetFocus
Exit Sub
End If
If IsDate(txtArrival.Value) = True Then
strFromdate = txtArrival.Value
Else
MsgBox "You have to choose a arrival date.", , "Booking"
Form_frmBooking.txtArrival.Value = ""
Form_frmBooking.txtArrival.SetFocus
Exit Sub
End If
strAvFromDate = DLookup("[AvFrom]", "tblObject", "[ObjectID] = " & strObject)
strAvToDate = DLookup("[AvTo]", "tblObject", "[ObjectID] = " & strObject)
strBookFromDate = DLookup("[Arrival]", "tblBooking", "[ObjectID] = " & strObject)
strBookToDate = DLookup("[Departure]", "tblBooking", "[ObjectID] = " & strObject)
If strFromdate <> "" Then
If strFromdate < strAvFromDate Or strFromdate > strAvToDate Then
MsgBox "You have to choose a arrival date between the Avaible from and Avaible to dates for the object you have choosen.", , "Booking"
Form_frmBooking.txtArrival.Value = ""
Form_frmBooking.txtArrival.SetFocus
Exit Sub
End If
If strFromdate <= strBookToDate And strFromdate >= strBookFromDate Then
MsgBox "You can not book this date because you have another booking at this time for the selected object", , "Booking"
Form_frmBooking.txtArrival.Value = ""
Form_frmBooking.txtArrival.SetFocus
Exit Sub
End If
End If
End Sub
So what will I do? Please help me...
Best Regardz,
Spikemannen