I am trying to perform a check of an appointment date field in an access database to verify that the user does not enter an overlapping appointment date and time. the database is bound to vb. I lock the txtbox field and force the user to use a cmd button to change the appointment. I am not tha good at this yet (obviously). I cannot get the record to update the date or display an error message if that date and time are taken
here is the mess I have so far.
Private Sub apptcheck()
'Defines variable used in date check
Dim apptdates As String
Dim newApptDate As String
'assigns value to from field for search
apptdates = datContactManager.Recordset("apptdate"
.Value
'Calls input box to check new appointment time and assigns variable
newApptTime = InputBox("Enter desired Appointment time"
'checks to see if the criteria is meet
If datContactManager.RecordSource = "select * from contactmanager were [apptDate]= #" & apptdates & "# and were [Time]= #" & newApptTime & "#" Then
MsgBox "That time is already taken for that day"
Exit Sub
Else:
txtAppointmentDate.Locked = False
txtAppointmentDate.Text = newApptDate
End If
End Sub
here is the mess I have so far.
Private Sub apptcheck()
'Defines variable used in date check
Dim apptdates As String
Dim newApptDate As String
'assigns value to from field for search
apptdates = datContactManager.Recordset("apptdate"
'Calls input box to check new appointment time and assigns variable
newApptTime = InputBox("Enter desired Appointment time"
'checks to see if the criteria is meet
If datContactManager.RecordSource = "select * from contactmanager were [apptDate]= #" & apptdates & "# and were [Time]= #" & newApptTime & "#" Then
MsgBox "That time is already taken for that day"
Exit Sub
Else:
txtAppointmentDate.Locked = False
txtAppointmentDate.Text = newApptDate
End If
End Sub