I have a form called frmGetTime that contains three combo boxes
1.cboHour
Row Source Type = Value List
Row Source = 1;2;3;4;5;6;7;8;9;10;11;12
2. cboMinutes
Row Source Type = Value List
Row Source = 00;15;30;45
3. cboAMPM
Row Source Type = Value List
Row Source = AM;PM
and two command buttons
1.cmdCanel
2.cmdOK
The problem I am having is that when the user press cancel
it should close the form, which is does; but then it also places 12:00 AM in the text box
why is access placing 12:00 AM in the text box? what can I do to solve it?
Listed below is the full code
DisplayTime module
frmGetTime
Newbie in search of knowledge
1.cboHour
Row Source Type = Value List
Row Source = 1;2;3;4;5;6;7;8;9;10;11;12
2. cboMinutes
Row Source Type = Value List
Row Source = 00;15;30;45
3. cboAMPM
Row Source Type = Value List
Row Source = AM;PM
and two command buttons
1.cmdCanel
2.cmdOK
The problem I am having is that when the user press cancel
Code:
Private Sub cmdExit_Click()
DoCmd.Close acForm, "frmGetTime"
End Sub
it should close the form, which is does; but then it also places 12:00 AM in the text box
why is access placing 12:00 AM in the text box? what can I do to solve it?
Listed below is the full code
DisplayTime module
Code:
Option Compare Database
Option Explicit
Public CompleteTime As Date
Public Function GetTime(txtbox As Control) As Date
DoCmd.OpenForm "frmGetTime", , , , , acDialog
txtbox = Format(CompleteTime, "hh:mm AM/PM")
End Function
frmGetTime
Code:
Option Compare Database
Option Explicit
Private Sub cmdExit_Click()
'CompleteTime = ""
DoCmd.Close acForm, "frmGetTime"
End Sub
Private Sub cmdOK_Click()
Dim ctl As Control
Dim strRequired As String
For Each ctl In Form.Controls
If TypeOf ctl Is ComboBox Then
If IsNull(ctl) Or ctl = "" Then
strRequired = strRequired + ctl.Name & ", "
Else
End If
End If
Next
If strRequired = "" Or IsNull(strRequired) Then
CompleteTime = Forms!frmGetTime!cboHour & ":" _
& Forms!frmGetTime!cboMinutes & Forms!frmGetTime!cboAMPM
DoCmd.Close acForm, "frmGetTime"
Else
MsgBox strRequired & "is a required field"
End If
End Sub
Newbie in search of knowledge