Concatenating a Text variable with a Long Integer variable

G

Guest

Hello,

I am trying to concatenate a Text Variable and a Long Integer. Is there any
way to make this happen and not get a 'Type Mismatch' error? I am trying to
have 'page_num' (which is defined as 'Text' in the underlying table), show
the hard-coded Page # + the 'cyclenum' (which is defined as a Long Integer in
the underlying table). I have tried putting quotes around the hard-coded
Page #, but I can't capture 'cyclenum'. As you can see, I also tried to 'Dim
cyclenum As String' (now commented out), but that didn't work either. the
'page_num' field MUST be Text, as some of them include characters and
numbers. Is there a way to do this? Thank you, the code is below.

Private Sub cyclenum_AfterUpdate()
'Dim cyclenum As String
If cyclenum = 0 Then
FrameStudyPhase = 1
'Me.preg_test.Enabled = True
Me.page_num = 16 + "-" + cyclenum
ElseIf cyclenum = 99 Then
FrameStudyPhase = 3
'Me.preg_test.Enabled = False
Me.page_num = 38 + "-" + cyclenum
ElseIf cyclenum = 88 Then
FrameStudyPhase = 4
'Me.preg_test.Enabled = False
Me.page_num = 46 + "-" + cyclenum
Else: FrameStudyPhase = 2
'Me.preg_test.Enabled = False
Me.page_num = 27 + "-" + cyclenum
End If
End Sub
 
A

Allen Browne

Use the Ampersand as the concatenation operator, and close the number in
quotes, e.g.:
Me.page_num = "16-" & cyclenum

If that still fails, use CStr() to typecast it:
Me.page_num = "16-" & CStr(cyclenum)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top