Solved

type Mismatch on text and function concatenation

Posted on 2014-01-27
8
354 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 70

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 - Microsoft MVP, Access and Data Platform) earned 125 total points
ID: 39812780
Form Caption ?

Private Sub Form_Load()

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

End Sub
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

735 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