Calendar on multiple forms

thart21

Registered User.
Local time
Today, 00:43
Joined
Jun 18, 2002
Messages
236
I can't seem to get my brain around this:

I have a simple calendar that, of course, I found here, that I want to use on three different forms. I have it working on one as long as I just want the dates to be entered on that particular form, but am assuming that, in order to use it in multiple forms I need to create a module. I tried the following in a module but get an error when selecting the date in pop up calendar on my form.

Sub ShowCalendar(ByRef DateCompleted As TextBox)

On Error GoTo Err_ShowCalendar

Dim frmCal As Form ' calendar form
Dim ctlD As Control ' date control on this form

Set ctlD = DateCompleted
DoCmd.OpenForm "Calendar", , , , , acDialog

Set frmCal = Forms("Calendar")
With frmCal
Set .DateControl = ctlD
.InitialDate = ctlD.Value
.Visible = True
End With

Exit_ShowCalendar:
Exit Sub

Err_ShowCalendar:
MsgBox Err.Description, vbCritical, "Error #" & Err.Number
Resume Exit_ShowCalendar

End Sub


Code for command button onclick event:

Private Sub Calendar_Click()

DateCompleted = Nz(DateCompleted, Date)
Call ShowCalendar(DateCompleted)


End Sub


This gives me the message "...can't find the form 'Calendar' referred to in a macro or expression or Visual Basic Code"

Any time I am using the calendar, the Date will go into the same table and same field "DateCompleted", just in different situations.


Any help would be appreciated!

Thanks,

Toni
 
See this Microsoft knowledge base article:

Microsoft Knowledge Base Article - 135369 ACC: How to Open Multiple Instances of a Form
 
This attachment may help getting the date into the field on a certain form.

Hope it helps
Dave
 

Attachments

I posted an example here using a calendar and textbox that you may find useful.
 

Users who are viewing this thread

Back
Top Bottom