Solved

type Mismatch on text and function concatenation

Posted on 2014-01-27
8
345 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

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 viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
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 …

708 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

12 Experts available now in Live!

Get 1:1 Help Now