type Mismatch on text and function concatenation

I am try to create the form caption on the fly,  it works on 1 form by not on another,

What am I missing?

Private Sub Form_Load()

   On Error GoTo Form_Load_Error

    Me.lblCaption_start.Caption = "CompanyName" & Year(Date) & " CONTRACT YEAR"
   
   On Error GoTo 0
   Exit Sub

Form_Load_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Load of VBA Document Form_frmPassword"
End Sub

Open in new window

Karen SchaeferBI ANALYSTAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Connect With a Mentor Database ArchitectCommented:
Form Caption ?

Private Sub Form_Load()

Me.Caption = "CompanyName " & Year(Date) & " CONTRACT YEAR"

End Sub
0
 
GozrehCommented:
is the "lblCaption_start" a Label Field ?
do you have a field on this form called "Date" ? you should type Date()
0
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
if you want to change the form's caption, you need to set the Text property of the form:

Me.text = "CompanyName" & Year(Date) & " CONTRACT YEAR"
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Also ... is CompanyName  supposed to be a Variable ?

Because as is the Caption is going to look like this:

CompanyName 2014 CONTRACT YEAR

?
0
 
Helen FeddemaConnect With a Mentor Commented:
Try saving the entire caption to a String variable and displaying it in the Immediate Window with a Debug.Print statement.  The syntax looks OK, but as another poster mentioned, there could be a problem if you have a field (or control) called Date, since it could be confused with the Date() function.
0
 
Karen SchaeferBI ANALYSTAuthor Commented:
THANKS FOR THE INPUT
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"you need to set the Text property of the form:"

Karen ... there is no such property 'text' of a Form.  So, I'm confused as to why 250 pts was assigned to this post ?

mmx
0
 
Karen SchaeferBI ANALYSTAuthor Commented:
sorry the points where suppose to be spread equally for time and effort.

K
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.