Catrina
April 5th, 2000, 02:37 PM
I have a form where the user enters a date in a text box. The date is held in a variable named PayEnding$. I have declared it public in a module. I have a label that is to print the date if the form is loaded again. I don't want it to print as the user is typing, only if the form is used again. Then if used a third time, I want the second date to show in the label. (Hope this makes since). Anyway, I can't get it to work. I have tested the PayEnding$, with labels on other forms, and the date is there, I just need help with the code to make the date label show the previous date entered and blank if no date was entered. Here is the code I currently have that doesn't work:
Dim A as Variant
Dim CurrDate as date
Dim B as Integer
If KeyAscii = 13 then
KeyAscii = 0
Zout$ = txtEnding.Text
If PayEnding$ = "" then
lblEnding.Visible = false
else
lblEnding.Visible = true
lblEnding.Caption = mid$(PayEnding$, 1, 2) + "/" + mid$(PayEnding$, 3, 2) + "/" + mid$(PayEnding$, 7, 2)
End If
If Val(mid$(Zout$, 1, 2)) < 1 Or Val(mid$(Zout$, 1, 2)) > 12 then
B = MsgBox("Invalid Month, Please enter again.")
End If
If Val(mid$(Zout$, 3, 2)) < 1 Or Val(mid$(Zout$, 3, 2)) > 31 then
B = MsgBox("Invalid Day, Please enter again.")
End If
If Val(mid$(Zout$, 5, 4)) < Val(mid$(CurrDate, 7, 2) + 2000) - 2 Or Val(mid$(Zout$, 5, 4)) > Val(mid$(CurrDate, 7, 2) + 2000) + 2 then
B = MsgBox("Invalid Year, Please enter again.")
End If
If B = 1 then
lblEnding.Caption = ""
txtEnding.Text = ""
txtEnding.SetFocus
Exit Sub
End If
A = MsgBox("This this date Correct?", vbYesNo, "PDP")
If A = 7 then
lblEnding.Caption = ""
txtEnding.Text = ""
txtEnding.SetFocus
else
txtCheck.SetFocus
End If
End If
PayEnding$ = Zout$
End Sub
Thank you for any help.
Catrina
Dim A as Variant
Dim CurrDate as date
Dim B as Integer
If KeyAscii = 13 then
KeyAscii = 0
Zout$ = txtEnding.Text
If PayEnding$ = "" then
lblEnding.Visible = false
else
lblEnding.Visible = true
lblEnding.Caption = mid$(PayEnding$, 1, 2) + "/" + mid$(PayEnding$, 3, 2) + "/" + mid$(PayEnding$, 7, 2)
End If
If Val(mid$(Zout$, 1, 2)) < 1 Or Val(mid$(Zout$, 1, 2)) > 12 then
B = MsgBox("Invalid Month, Please enter again.")
End If
If Val(mid$(Zout$, 3, 2)) < 1 Or Val(mid$(Zout$, 3, 2)) > 31 then
B = MsgBox("Invalid Day, Please enter again.")
End If
If Val(mid$(Zout$, 5, 4)) < Val(mid$(CurrDate, 7, 2) + 2000) - 2 Or Val(mid$(Zout$, 5, 4)) > Val(mid$(CurrDate, 7, 2) + 2000) + 2 then
B = MsgBox("Invalid Year, Please enter again.")
End If
If B = 1 then
lblEnding.Caption = ""
txtEnding.Text = ""
txtEnding.SetFocus
Exit Sub
End If
A = MsgBox("This this date Correct?", vbYesNo, "PDP")
If A = 7 then
lblEnding.Caption = ""
txtEnding.Text = ""
txtEnding.SetFocus
else
txtCheck.SetFocus
End If
End If
PayEnding$ = Zout$
End Sub
Thank you for any help.
Catrina