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

Type Mismatch on a variable

Status
Not open for further replies.

HebieBug

Programmer
Jan 8, 2001
354
JP
My understanding of a variable that is set to variant means that it can accept both charaters and numeric.
Tried something this morning:

Dim test as variant
Dim caption as variant
test = 0
caption = " " + test + " " + me.Text1

Up comes the error type mis match the problem is with the Test variable being placed within the caption
Have tried changing te caption to a sting ect...
Anyone mind going back to basis or me

 
Your problem is not with the variable dimmed as a variant, but the fact that you are ADDING (+) a string to a number when in fact you want to concatenate(&). But I beleive that a variant can either hold a string or a numeric, but not both at the same time. What I mean is that if a number is concatenate to a string, then the number is converted to a string first and this variant will hold only a string value.

David Paulson


 
Hi,
Try this out. Instead of using the + signe, use the & for concatenation.

caption = " " & test & " " & me.Text1


Mukund.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top