Solved

type Mismatch on text and function concatenation

Posted on 2014-01-27
8
347 Views
Last Modified: 2014-01-31
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

0
Comment
Question by:Karen Schaefer
8 Comments
 
LVL 10

Expert Comment

by:Gozreh
ID: 39812653
is the "lblCaption_start" a Label Field ?
do you have a field on this form called "Date" ? you should type Date()
0
 
LVL 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
ID: 39812689
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
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 125 total points
ID: 39812780
Form Caption ?

Private Sub Form_Load()

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

End Sub
0
 
LVL 75
ID: 39812803
Also ... is CompanyName  supposed to be a Variable ?

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

CompanyName 2014 CONTRACT YEAR

?
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 31

Assisted Solution

by:Helen_Feddema
Helen_Feddema earned 125 total points
ID: 39813245
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
 

Author Closing Comment

by:Karen Schaefer
ID: 39824534
THANKS FOR THE INPUT
0
 
LVL 75
ID: 39824714
"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
 

Author Comment

by:Karen Schaefer
ID: 39824741
sorry the points where suppose to be spread equally for time and effort.

K
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now