Hey all,
I'm still trying to learn but my needs are surpassing my studies at the moment. I'm hoping someone can take a look at the code below and let me know where to make the adjustment so that;
the time (i.e: 2:00 PM) is not listed in the cboAvailability dropdown if it is currently 2:01 PM. Currently if it's 3:00 PM, my clients are able to book 2:00, 2:30 etc. I would like hide this only if they select today's date. I wouldn't want it to hide 2:00 PM also for tomorrow let's say.
Does that make sense? I'm having a hard time trying to place it in this code below that I was originally assisted with.
Thank you kindly.
k3ll1n
I'm still trying to learn but my needs are surpassing my studies at the moment. I'm hoping someone can take a look at the code below and let me know where to make the adjustment so that;
the time (i.e: 2:00 PM) is not listed in the cboAvailability dropdown if it is currently 2:01 PM. Currently if it's 3:00 PM, my clients are able to book 2:00, 2:30 etc. I would like hide this only if they select today's date. I wouldn't want it to hide 2:00 PM also for tomorrow let's say.
Does that make sense? I'm having a hard time trying to place it in this code below that I was originally assisted with.
Thank you kindly.
k3ll1n
Code:
Public Function GetExcludedTimes(vDate As Date) As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim excluded As String
strSql = "Select AppointmentTime from tblAppointments where AppointmentDate = #" & Format(vDate, "dd\/mm\/yyyy") & "#"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSql)
If rs.BOF And rs.EOF Then
GetExcludedTimes = "0"
Else
Do Until rs.EOF
excluded = "#" & rs!AppointmentTime & "#" & "," & excluded
excluded = Replace(excluded, "##", "")
rs.MoveNext
Loop
GetExcludedTimes = excluded
End If
MyExit:
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
Code:
Public Sub GetCboDates(VarDate As Date)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSql As String
Dim StrCrit As String
StrCrit = GetExcludedTimes(VarDate)
If StrCrit = "0" Then
strSql = "select * from tblAppointmentHoursDaily"
Else
strSql = "select * from tblAppointmentHoursDaily where Hours not in (" & StrCrit & ")"
End If
'Screen.ActiveForm.cboAvailability.RowSource = ""
Forms!frmMainNavigation!NavigationSubform.Form!cboAvailability.RowSource = ""
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSql)
Do Until rs.EOF
'Debug.Print rs!Hours
'Screen.ActiveForm.cboAvailability.AddItem rs!Hours
Forms!frmMainNavigation!NavigationSubform.Form!cboAvailability.AddItem rs!Hours
rs.MoveNext
Loop
MyExit:
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub