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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle Button & Calendar control to enter a date into a text box

Status
Not open for further replies.

melt333

Technical User
Sep 26, 2002
12
GB
OK, this has been annoying me for days....

I have created a form with a calendar control on it.
I have created a Macro - action(SetValue), Item: Forms![calendar].visible; expression: Not Forms![calendar].visible
I have another form with the toggle button, and set the ONClick event to the Macro.

Once I press the toggle button I get the error:
"A problem occured while 'db' Database was communicating with the OLE server or ActiveX Control.
Close the OLE Server and restart it outside the 'db' Database. Then try the original operation in the 'db' Database."

Any Ideas?

Also, once this toggle button works, how would I link the value selected on the Calendar control to the date field on my form??

Cheers,

Mark
 
Not really sure what you want to happen but I'll make some assumptions.

1. that the calendar control works on the calendar form.
2. that you want to open it, pick a date, have it close after putting the date on your form with the button.
3. That the calendar is not a subform.

The calendar doesn't show a "On Click" event on the property window but does show in the procedure window for the control in VB editor. So open the calendar form and goto VB Editor and paste in ...

Private Sub calendar_Click()
Forms![Form2]![thedate] = Me.calendar.Value
DoCmd.Close acForm, "calendar"
End Sub

Where "form2" is the form with the button and "thedate" is the field waiting for a date from the calendar.

On form2 for the OnClick event for your button simply use

Private Sub togglecalendar_Click()
DoCmd.OpenForm "calendar"
End Sub

Where "togglecalendar" is the name of your button.
Be sure to have a text box called "thedate" or have it match what was referenced on the calendar form.

HTH
Tim

 

Hi:

In Access2000, I use MS' ActiveX Calendar. That control is bound to the field, "TransactionDate". I have a text box that is also bound to "TransactionDate". Selecting the date from the Calendar control populates the text box. No code in either control. 'Course I don't use a macro and I don't have a toggle button there...

Gus Brunston [glasses] An old PICKer, using Access2000.
 
can you use the same button to enter dates in other fields/records?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top