Hey all,
Wondering if anyone can provide a work around for this issue I'm having.
The DB I've created is for our department at work and once complete, I will place it on a shared drive and provide shortcuts to it.
The issue I'm having is that one of my Appointment Date field is required before it'll show the Available Times for that day. I have tried using Input Masks but no matter what I do, the Date entry is tied to how Windows has it's date formatted in the control panel.
Almost all computers in the office have a date format of 2016.06.15 (Periods as spacers). My form will not accept periods in the date. It spits out an error when opening the cbo dropdown.
If I set the system time format to yyyy-MM-dd in the control panel, everything works. But every morning when the system is turned on, the format resets to periods. I don't see our IT dept making an exception for this and changing all the system defaults.
I'm not sure if there's something I can throw in the VBA code to allow them, or another alternative. I would consider myself still pretty new to Access.
I was assisted with the code below.
The two main functions of my Module are;
Wondering if anyone can provide a work around for this issue I'm having.
The DB I've created is for our department at work and once complete, I will place it on a shared drive and provide shortcuts to it.
The issue I'm having is that one of my Appointment Date field is required before it'll show the Available Times for that day. I have tried using Input Masks but no matter what I do, the Date entry is tied to how Windows has it's date formatted in the control panel.
Almost all computers in the office have a date format of 2016.06.15 (Periods as spacers). My form will not accept periods in the date. It spits out an error when opening the cbo dropdown.
If I set the system time format to yyyy-MM-dd in the control panel, everything works. But every morning when the system is turned on, the format resets to periods. I don't see our IT dept making an exception for this and changing all the system defaults.
I'm not sure if there's something I can throw in the VBA code to allow them, or another alternative. I would consider myself still pretty new to Access.
I was assisted with the code below.
The two main functions of my Module are;
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 = #" & vDate & "#"
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
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