Help please :( combining words in VBA

AngelicaMiranda

Registered User.
Local time
Today, 21:04
Joined
Nov 30, 2011
Messages
20
hi! I have a table with field names StudentsID, FirstName, MiddleName, LastName,Course,Address

I created a form with combo box that when you choose any of the StudentsID, it will automatically populates the other textboxes (such as Name,Course,Address). My problem is, I need to combine the 3 fields in one which is FirstName, MiddleName and LastName into Name(only). I tried this code:

Dim strFirstName As String
Dim strMiddleName As String
Dim strLastName As String
Dim strName As String

strName = "Hello" & strFirstName & " " & strMiddleName & " " & strLastName

but it gives me error, can anyone help me please?

Thanks in advance :)
 
If this;
Code:
Dim strFirstName As String
Dim strMiddleName As String
Dim strLastName As String
Dim strName As String

strName = "Hello" & strFirstName & " " & strMiddleName & " " & strLastName
is the full code you have not assigned values to your first three string variables.
 
If this;
Code:
Dim strFirstName As String
Dim strMiddleName As String
Dim strLastName As String
Dim strName As String

strName = "Hello" & strFirstName & " " & strMiddleName & " " & strLastName
is the full code you have not assigned values to your first three string variables.


Like this?
Dim strFirstName As String = "Angela"
Dim strMiddleName As String = "Panda"
Dim strLastName As String = "Moore"

But I shouldn't be the one who is inputting the names, it should read the value in my tables and display it on one of my textbox in form. :(
 
You'd need to do something along the lines of;
Code:
Dim strFirstName As String
Dim strMiddleName As String
Dim strLastName As String
Dim strName As String

strFirstName = Me.FirstNameField
strMiddleName = Me.MiddleNameField
strLastName = Me.LastNameField

strName = "Hello" & strFirstName & " " & strMiddleName & " " & strLastName

Me.WelcomeMsgField = strName
This presupposes that you are working with form that has Bound fields that contains the first, middle and last names, and an unbound field to display your concatenated message
 
You'd need to do something along the lines of;
Code:
Dim strFirstName As String
Dim strMiddleName As String
Dim strLastName As String
Dim strName As String

strFirstName = Me.FirstNameField
strMiddleName = Me.MiddleNameField
strLastName = Me.LastNameField

strName = "Hello" & strFirstName & " " & strMiddleName & " " & strLastName

Me.WelcomeMsgField = strName
This presupposes that you are working with form that has Bound fields that contains the first, middle and last names, and an unbound field to display your concatenated message

Oh I get it, thank you sooo much for helping me :)
 

Users who are viewing this thread

Back
Top Bottom