S
Silvester
In my A2000 combobox users may enter time in 12 or 24 hour formats. The code
below only handles strings. How can I get the notinlist event to first check
in both 12 & 24 hr formats and fire if the timing really does not exist.
I'd like to amend the code below to handle Time format.
Private Sub cboTimings_NotInList(NewData As string, Response As Integer)
On Error GoTo err_cboTimings_NotInList
Dim ctl As Control
Dim strSQL As String
' Return Control object that points to combo box.
Set ctl = Me.cboTimings
' Prompt user to verify they wish to add new value.
If MsgBox("This timing is not listed in the regular meeting timings." &
vbCrLf & "Add it?", vbQuestion + vbOKCancel, "Add ?") = vbOK Then
' Set Response argument to indicate that data is being added.
Response = acDataErrAdded
' Add string in NewData argument to products table.
NewData = FormatDateTime(NewData, vbShortTime)
strSQL = " INSERT INTO QryMeetingTimings ( MeetingTiming ) SELECT '"
& NewData & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
ctl.Value = NewData
DoCmd.SetWarnings True
Else
' If user chooses Cancel, suppress error message and undo changes.
Response = acDataErrContinue
ctl.Undo
End If
exit_cboTimings_NotInList:
Exit Sub
err_cboTimings_NotInList:
If Err = 2113 Then
Err = 0
Resume Next
Else
MsgBox Str(Err)
MsgBox Err.Description
Resume exit_cboTimings_NotInList
End If
below only handles strings. How can I get the notinlist event to first check
in both 12 & 24 hr formats and fire if the timing really does not exist.
I'd like to amend the code below to handle Time format.
Private Sub cboTimings_NotInList(NewData As string, Response As Integer)
On Error GoTo err_cboTimings_NotInList
Dim ctl As Control
Dim strSQL As String
' Return Control object that points to combo box.
Set ctl = Me.cboTimings
' Prompt user to verify they wish to add new value.
If MsgBox("This timing is not listed in the regular meeting timings." &
vbCrLf & "Add it?", vbQuestion + vbOKCancel, "Add ?") = vbOK Then
' Set Response argument to indicate that data is being added.
Response = acDataErrAdded
' Add string in NewData argument to products table.
NewData = FormatDateTime(NewData, vbShortTime)
strSQL = " INSERT INTO QryMeetingTimings ( MeetingTiming ) SELECT '"
& NewData & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
ctl.Value = NewData
DoCmd.SetWarnings True
Else
' If user chooses Cancel, suppress error message and undo changes.
Response = acDataErrContinue
ctl.Undo
End If
exit_cboTimings_NotInList:
Exit Sub
err_cboTimings_NotInList:
If Err = 2113 Then
Err = 0
Resume Next
Else
MsgBox Str(Err)
MsgBox Err.Description
Resume exit_cboTimings_NotInList
End If