Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 21st, 2009, 11:30 AM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Default Modifying Table field after update

Hi All,

I'm not a very adept VBA coder, so I am humbly asking for assistance.

I have a table with the following fields:
ID
LastName
FirstName
LastFirst

I have a form to add new contacts to the list. When a record is updated with First and Last Name, I would like to have the database update LastFirst with 'LastName' & ", " & 'FirstName'

I put an event on After Update for
Code:
LastFirst = LastName & ", " & FirstName
and the first record worked fine. Since that first record, I cannot advance to a new record, and when I try to close the form, I get an error that the database cannot be saved, so obviously I am not doing something right. I 'THINK' I need to reference the record that I am on (ID maybe) in my VBA, but I'm not sure how to do that or even if that is what needs to be done.

I use the LastFirst field for 2 purposes:
1. I populate a combo box on a different form with this field.
2. I use this to link the two tables together for reporting.

Any suggestions would be greatly appreciated!
-Wd
 
Old August 21st, 2009, 11:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

My answer would not be fully helpful for you, but using a volatile field to link tables is not a good idea, and also to fill a combo you can build that field on the fly using SQL.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
The Following User Says Thank You to gbianchi For This Useful Post:
Wd2048 (August 21st, 2009)
 
Old August 21st, 2009, 11:59 AM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by gbianchi View Post
My answer would not be fully helpful for you, but using a volatile field to link tables is not a good idea, and also to fill a combo you can build that field on the fly using SQL.
Ok, I would be willing do to that. Don't really care how the data gets there as long as it is there. How would I go about that?
 
Old August 21st, 2009, 01:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

To populate the combo just modify your query to get lastname, firstname.. something like
SELECT lastname & ', ' & firstname AS fullname FROM table...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
The Following User Says Thank You to gbianchi For This Useful Post:
Wd2048 (August 21st, 2009)
 
Old August 21st, 2009, 02:07 PM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
Default

I think I am on my way! Thanks so much!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying table dynamically,storing dropdown value santy_capri Classic ASP Databases 0 July 25th, 2006 06:09 AM
Table field update ibelta Access 4 February 12th, 2005 08:22 PM
Update city field based on zip field nganb SQL Server ASP 0 April 22nd, 2004 10:30 PM
Modifying long text in a long field sajsal Classic ASP Databases 1 February 20th, 2004 12:36 PM
auto update table field nkrukovsky Access VBA 2 November 4th, 2003 05:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.