0

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!

10
  • 1
    This is certainly possible but I would recommend you not saving the full name, which adds complication and creates data redundancy, which you always want to avoid in your database design. Just store first and last names and combine them when they are displayed or printed. Commented May 13, 2015 at 17:46
  • So, 1 column that stores First name, last name, full name and you want to know if you can have a hidden input field for what purpose? VBA can handle this quite easily with 3 different fields Commented May 13, 2015 at 17:47
  • @Invent-Animate No, these are 3 separate columns. Technically one of them (full name) is being sent to a completely different database, but that is irrelevant for the sake of this question. The hidden input field would just easily pass data without the user having to input redundant information. Commented May 13, 2015 at 17:50
  • "I am creating an access database that requires I have a column for the following three fields " - What is that saying then? Commented May 13, 2015 at 17:51
  • @Invent-Animate I apologize, that was very poorly worded. I altered my original statement to be "I am creating an access database that requires I have a separate column for each of the following three fields" Commented May 13, 2015 at 17:53

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

5 Comments

This makes sense, but it isn't parsing to my database upon click of the submit button. Would you know why?
Well, there's a few possibilities. Did you create new text boxes to accommodate my answer? Were you using any VBA before? What changes did you make? What isn't it doing that you need it to?
Did you add Option Explicit to the module's Declarations section and then run Debug->Compile and fix any problems the compiler complained about?
I figured it out. Instead of assigning the values to FullName (the title of the Column) I was supposed to assign them to the name of the textbox. Very new to VBA, so still learning. Thanks Invnet, everything is good now!
Oh, yeah - I didn't know that was the name of your column!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.