T
Tandy
Recently I made a form that prompts my user for the year they would like to
enter with the code below. I would like to modify the code to prompt my user
for the date they would like to enter in short day format. So when my user
opens the form, I would like for the user to be prompted for the date they
would like to enter (1/1/2005) and have that date shown in a textbox called
txtShowMonth. I have tried several times to do this myself, but I don't have
a good enough grasp of code. Also, I do not want any suggestions for
alternatives (such as a pop up calendar), this is how I need this to be for
my form... sorry
Please help!
Private Sub Form_Open(Cancel As Integer)
Dim strShowYear As String
Dim blnDone As Boolean
' Prompt the user for the year to be shown initially.
' We'll suggest next year as a default.
' In case of erroneous entry, continue prompting until
' a valid year is given, or the prompt is cancelled.
Do
strShowYear = InputBox( _
"What year do you want to edit?", _
"Enter Year", _
CStr(Year(Date) + 1))
Select Case True
Case (Len(strShowYear) = 0)
Cancel = True
blnDone = True
Case (Not IsNumeric(strShowYear)), _
(Val(strShowYear) < 1800), _
(Val(strShowYear) > 5000)
MsgBox "That's not a valid year!", _
vbExclamation, "Invalid Entry"
Case (Val(strShowYear) < (Year(Date) - 10)), _
(Val(strShowYear) > (Year(Date) + 10))
If MsgBox( _
"You entered " & strShowYear & _
", which seems odd. " & _
"Are you sure?", _
vbQuestion + vbYesNo, _
"Please Confirm") _
= vbYes _
Then
blnDone = True
End If
Case Else
blnDone = True
End Select
Loop Until blnDone
If Cancel <> True Then
Me.txtShowYear = strShowYear
Me.Requery
End If
End Sub
enter with the code below. I would like to modify the code to prompt my user
for the date they would like to enter in short day format. So when my user
opens the form, I would like for the user to be prompted for the date they
would like to enter (1/1/2005) and have that date shown in a textbox called
txtShowMonth. I have tried several times to do this myself, but I don't have
a good enough grasp of code. Also, I do not want any suggestions for
alternatives (such as a pop up calendar), this is how I need this to be for
my form... sorry
Please help!
Private Sub Form_Open(Cancel As Integer)
Dim strShowYear As String
Dim blnDone As Boolean
' Prompt the user for the year to be shown initially.
' We'll suggest next year as a default.
' In case of erroneous entry, continue prompting until
' a valid year is given, or the prompt is cancelled.
Do
strShowYear = InputBox( _
"What year do you want to edit?", _
"Enter Year", _
CStr(Year(Date) + 1))
Select Case True
Case (Len(strShowYear) = 0)
Cancel = True
blnDone = True
Case (Not IsNumeric(strShowYear)), _
(Val(strShowYear) < 1800), _
(Val(strShowYear) > 5000)
MsgBox "That's not a valid year!", _
vbExclamation, "Invalid Entry"
Case (Val(strShowYear) < (Year(Date) - 10)), _
(Val(strShowYear) > (Year(Date) + 10))
If MsgBox( _
"You entered " & strShowYear & _
", which seems odd. " & _
"Are you sure?", _
vbQuestion + vbYesNo, _
"Please Confirm") _
= vbYes _
Then
blnDone = True
End If
Case Else
blnDone = True
End Select
Loop Until blnDone
If Cancel <> True Then
Me.txtShowYear = strShowYear
Me.Requery
End If
End Sub