Concatenate value and Store into variable

furnitureheaven

Registered User.
Local time
Today, 14:35
Joined
Aug 5, 2008
Messages
36
Hi,
I am stuck in this, I have a form with combo box and ref no( text field), I want to concat the value of Combo box with 0 and concat it with Refno. In my table combo box field is in number and RefNo field is in Text.

Could any one tell how I can set this, My code is this.


Code:
[SIZE=3][FONT=Times New Roman]Dim it as string[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]it = (" & [Forms]![LegFile].[Combo8] + 0 + [Forms]![LegFile].[frmRefNo] & ")[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]DoCmd.FindRecord acDataForm, acEntire, "it", acSearchAll, , acCurrent[/FONT][/SIZE]
 
it = [Forms]![LegFile].[Combo8] + 0 + [Forms]![LegFile].[frmRefNo]

Is that what you are looking for?? If refno is text then IT will be text as well. No need to quote it.
 
it = [Forms]![LegFile].[Combo8] + 0 + [Forms]![LegFile].[frmRefNo]

Is that what you are looking for?? If refno is text then IT will be text as well. No need to quote it.

Not exactly, as I said, I have Combo and Text box on form, what I want if I select

Combo box value =1 and
Text box value =158 then

It should store in the variable 10158 So

It = 10158

So if I use this

it = [Forms]![LegFile].[Combo8] + 0 + [Forms]![LegFile].[frmRefNo]

then its only store

it= 158,

How I concatenate the combo box value with text box and 0 between them.
 
The problem lays in the +, it adds the numbers instead of concatinating.... This is why I allways stress people use & to concatinate instead of the + unless you are sure how + EXACTLY works!
1 + 0 + 158 = 159 though??

You could also try
"" & [Forms]![LegFile].[Combo8] & 0 & [Forms]![LegFile].[frmRefNo]
 
The problem lays in the +, it adds the numbers instead of concatinating.... This is why I allways stress people use & to concatinate instead of the + unless you are sure how + EXACTLY works!
1 + 0 + 158 = 159 though??

You could also try
"" & [Forms]![LegFile].[Combo8] & 0 & [Forms]![LegFile].[frmRefNo]

Thats now work, thanks for your help.
 

Users who are viewing this thread

Back
Top Bottom