Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update table from concatenate field.

Status
Not open for further replies.

gtroiano

Technical User
Nov 7, 2001
99
0
0
US
i can't figure out anything lately. does anyone know how i can do this:
i have a text box on a subform (txtFullName) which is just the first name and last name combined (txtFirstName) and (txtLastName), respectively. i need the combined name (txtFullName) to be added to the table. i have been trying to use an SQL update on the text box's afterupdate but i can't seem to get it to work. any help would be greatly appreciated.

jerry.
 
Well, this may not be the best way, but it may work (WARNING: I haven't tested it).

On your After Update property type:
Dim strSql as String

strSql = UPDATE TABLE SET NAME = txtFullName WHERE <some field on your form with the key = field in database>

DoCmd.RunSQL strSql

Give that a shot (and good luck),
Birgit
 
This the code i used but it does not update my table.


Private Sub txtFullName_AfterUpdate()
Dim strSql As String

strSql = &quot;UPDATE tblAddressBook SET tblAddressBook.FullName = txtFullName WHERE tblAddressBok.EmailId = EmailId&quot;

DoCmd.RunSQL strSql

End Sub

i have abosultely no idea what is wrong. any help?
jerry.
 
nevermind kids. i figured it out. thanks.

jerry.
 
Even though you have it... here is another way for those who are not as well versed in the code:

1) create the field in the table design view.

2) create an update query which lists only the field you want to create from the merged data.

3) in the Update To row list the fields you want to combine to create the new field, e.g.:

[FirstName] & &quot; &quot; & [LastName]

The quote/space/quote in the middle simply puts a space between the first and last names if you want it. Otherwise, omit the quotes and second ampersand and the two names would run together as one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top