Two text field values to update one table field

morlan

Registered User.
Local time
Today, 21:24
Joined
Apr 23, 2003
Messages
143
I have a form with two text fields. I want to be able to enter values into both of them and these two values would combine and be added to one table field.

eg. If I have a text box for Firstname and one of Surname, the values for these would be added to just one field in the table called Fullname.
 
For searching purposes I think it would be better to keep them as separate fields in the table.

If you wanted them to be joined for report purposes you can join them together in a query or directly in the report by concatenating the fields:

In your query design or report you'd join them:

[firstname] & " " & [lastname]
 
Ally said:
For searching purposes I think it would be better to keep them as separate fields in the table.

If you wanted them to be joined for report purposes you can join them together in a query or directly in the report by concatenating the fields:

In your query design or report you'd join them:

[firstname] & " " & [lastname]

Thanks but the values have to be held in one field.

Here is exacly what I'm trying to do.

I have a serial number which always starts with 0770375 and then the last three numbers are different for each item. It would speed up the data inputing process If I didnt have to input 0770375 for every record.
So my idea was to have two text fileds, one with the value "0770375" and that value would stay static for each record, (I would also have the option to edit that field if the first few digits of the serial number changed) and another field where I could enter the last three digits of the serial number. These two values would then be concatenated and added as a single value into one table field.

Does anyone have any better ideas as to how I could do this?
 
Not sure if this is the best way to do this but you could do something like:

Private Sub Serial_AfterUpdate()
Dim FirstBitOfSerial
FirstBitOfSerial = "0770375"

Me.Serial = FirstBitOfSerial & Me.Serial
End Sub


This automatically updates and gives you the entire serial number.
Also you can just change the firstBitOfSerial to get the new parts.

Hope it helps a little
Steve
 
Morlan,

In the BeforeUpdate event of your form, put code similar to this:
Code:
Dim Prefix as string
Dim Suffix as string

Prefix = Me.txtSerialPrefix.value 'txtSerialPrefix is the name of a textbox
Suffix = me.txtSerial.value 'txtSerial is the name of another textbox

me.txtSerial = Prefix & Suffix

You will, I think, want to leave the prefix textbox as unbound. Work with it and I'm sure you'll soon have it under control.

Regards,
Tim
 
Sorry Steve -- wasn't trying to step on your toes... Didn't see your post until after I sent mine out.
 
the more ideas the better with these things is what i always say. Then at least you get a choice as to solution to use.

No probs :):D :)
Steve
 
similar issue

i have a similar issue with the one that morlan had initially

i need 3 fields: firstname, lastname and and third which would be populated by both.

i need to do this because, well, i have 1 main projects table linked in many-to-many to two other tables: students and information. i have setup some combo boxes to create the linkage between the first one and the other two, but here i need to have first name and last name !!!! without em, there would be confusion.

at the time i only have one fullname field in thse tables, but i need to have the other two, first name and last name.

anyone got any ideas ?
 
Last edited:
fixed this problem by using a row source modification:

SELECT tblStudent.StudID, tblStudent.LastName & ", " & tblStudent.FirstName AS Expr1 FROM tblStudent ORDER BY tblStudent.LastName;


it works awesomely !!!
 
pono1 said:
Morlan,

In the BeforeUpdate event of your form, put code similar to this:
Code:
Dim Prefix as string
Dim Suffix as string

Prefix = Me.txtSerialPrefix.value 'txtSerialPrefix is the name of a textbox
Suffix = me.txtSerial.value 'txtSerial is the name of another textbox

me.txtSerial = Prefix & Suffix

You will, I think, want to leave the prefix textbox as unbound. Work with it and I'm sure you'll soon have it under control.

Regards,
Tim


Thanks,

Thats the one I used :)
 

Users who are viewing this thread

Back
Top Bottom