Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Picker Control Question

Status
Not open for further replies.

Ray1127

Programmer
Feb 22, 2002
231
US
I have a form to be used for data entry. In the table there are 3 date fields. Date Record was created. The Date the member was called and the Date of the appointment. The last 2 dates are null un the table until the user enters the data. I use date picker controls on the form for Data entry. However, everytime the user goes to a new record in the form an error is generated because those 2 date fields are null. I don't want the checkbox to display I've set the default to now() but I still get the error message. I tried taking the control Source field out and updating it after the control is updated but the update method never runs even if the date picker is changed. I'm using Access 2000 and I'm stumped. Any help would be appreciated.
 
an error is generated"
That is not very helpful. It is like going to a mechanic and saying there is a problem when you are driving, and no more information.

1. What is the error message?
2. What is the code?
3. Which line of code gets the error?
etc.

For events do not happen if the change is done by code not by a user action. In other words if you update a control through code the beforeupdate and afterupdate events do not occur. You would need to put the code in the date picker control.
 
The error is "Can't set Value to NULL when Checkbox property = False." It occurs on the form when changing records and the record has a null in the date field. The date field is the control source for the date picker control.
 
Ok, I made the default for the field as 1/1/1900 and made the Date Picker Control Visible property = False until the required checkbox is checked. Worked fine changed the date for 2-3 records did a search for a specific record and all worked fine. Closed the DB and went back in to retest and now everytime I change records I get the following error
An error occurred in a call to the Windows Date and Time Picker Control. There is no code behind the control. There is a checkbox control that sets the visibility of the control. If the checkbox is checked the control is visible if not the control is not.

In the Current Event of the form I have the following 3 lines of code. After commenting it out the error goes away.

' If Me.dtappt < Format(Now(), "mm/dd/yyyy") Then
' Me.dtappt.Visible = False
' End If

I commented out the above 3 lines of code and set the visibility = Yes for all cases it works fine. There is no error. What is wrong?







 
Not sure if this will work. The format function returns a string and you are comparing it to a date. Access may be able to figure it out, but I am not sure. I would get rid of the format.
Me.dtappt < date()

Also not sure where the focus is but you can not hide a control with the focus.
 
I'll try that. I tried now() but it included the time with wasn't what I wanted. That's why the format function was used.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top