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

Type mismatch error 1

Status
Not open for further replies.

jivetrky

MIS
Jun 16, 2006
38
US
I found some example code to add a popup calendar to a form to allow a user to select a date. I imported the code and forms into my database. I changed the record name to the name of my date field I want populated in the property control. When I changed everything I was suppose to change, I get a type mismatch error. What am I doing wrong? It works in the examble I down loaded. Your help would be appreciated.

This is what I changed in the control for onclick.

=CalendarFor([Opened Date])

Here is the code.

Option Compare Database
Option Explicit

'Calendar form variable:
Public gtxtCalTarget As TextBox 'Text box to return the date from the calendar to.

Public Function CalendarFor(txt As TextBox, Optional strTitle As String)
On Error GoTo Err_Handler
'Purpose: Open the calendar form, identifying the text box to return the date to.
'Arguments: txt = the text box to return the date to.
' strTitle = the caption for the calendar form (passed in OpenArgs).

Set gtxtCalTarget = txt
DoCmd.OpenForm "frmCalendar", windowmode:=acDialog, OpenArgs:=strTitle


Exit_Handler:
Exit Function

Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, vbExclamation, "CalendarFor()"
Resume Exit_Handler
End Function
 
I changed the record name to the name of my date field "
Is this also the name of the text box? Your function is looking for a text box to be passed in.
 
That worked. I forgot to look at the text box name. I assumed it was the name of my record. That's what you get when you assume. Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top