Ryan_W4588
Ryan_W4588

Reputation: 668

Access Form Input - Auto-Fill as User Passes Data

I am creating an access database that requires I have a separate column for each of the following three fields (which are related to my question): First name, last name, full name (syntax: "last, first").

I was wondering if there was a way that I could have a hidden input field (which would be the "full name" field). This hidden field would be filled with the data the user types in for "first name" and "last name", and would parse to the database all the same. Is this possible using basic Forms in Microsoft Access? Could I code the value for the field to be the user's input.

TIA!

Upvotes: 0

Views: 415

Answers (1)

Mark C.
Mark C.

Reputation: 6450

In your form, if you have 2 inputs for First Name and Last Name, we can utilize VBA to simply concatenate our strings for us.

For this example, I named my textboxes txtFirstName and txtLastName, respectively.

I then created a button to simulate your Submit button click, and here's the code to create the full name. What you do with it is up to you.

Dim FirstName, LastName, FullName As String

FirstName = Me.txtFirstName
LastName = Me.txtLastName

FullName = LastName & ", " & FirstName
Debug.Print FullName  'Optional; just to show you results

enter image description here

Upvotes: 1

Related Questions