Basic coding please help

Mcgrco

Registered User.
Local time
Today, 09:47
Joined
Jun 19, 2001
Messages
118
I have a active xcalendar on a form. On click it updates a text box on the form and updates a tbale with the date. i want to put a button on the form that closes the form only when the date in the text box = the calender. IF the text box is blank, then I want a message to appear. the code im trying to use is. Im just learrning so apologises if the code looks stupid. Thanks

Private Sub Command9_Click()
If dateselect = ActiveXCtl0 Then
DoCmd.Close
End If
If dateselect = "" Then
MsgBox "Date Validation", vbInformation, "Blank Date"
End If
End Sub
 
Hello,

If the textbox is bound to a table, why not just set the field required property in table design view to yes. This way if the user trys to leave the form without entering a date, Access will pop a MsgBox that says dateselect cannot contain an empty value.

Robert
 
Thanks Robert but the text box is based on the calender. i want to see how the proper code would be structered for refernce. Can anyone else help. thanks
 
How about this?

Private Sub Command9_Click()
If dateselect.Value = ActiveXCtl0 Then
DoCmd.Close
else
If dateselect = "" Then
MsgBox "Date Validation", Information, "Blank Date"
end if
End If

End Sub
 
hi I am using the calander control and this code links the calender to the text boxes...I'm not sure if it is what you are looking for though...

Private Sub cmdSetDates_Click()
On Error GoTo cmdSetDates_Error

If cmdSetDates.Caption = "Set Beginning Date" Then
BeginDate = calSetDates.value
cmdSetDates.Caption = "Set Ending Date"
Else
EndDate = calSetDates.value
cmdSetDates.Caption = "Set Beginning Date"
End If

Exit Sub

cmdSetDates_Error:
MsgBox "Error # " & Err.Number & ": " & Err.Description
Exit Sub

End Sub


[This message has been edited by mtc67 (edited 07-03-2001).]
 

Users who are viewing this thread

Back
Top Bottom