Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus batch bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Access 2007 - copy calculated reference number to underlying table

Reply  
Thread Tools
JoeBlack999's Avatar
Computer Specs
Member with 77 posts.
 
Join Date: May 2008
Experience: Intermediate
11-Dec-2008, 08:00 AM #1
Question Solved: Access 2007 - copy calculated reference number to underlying table
I haven't used Access for about a year and rust has set in. I have been asked to generate a reference number to identify clients. The reference number uses the first three letters from each of the clients first and last name and the unique (autonumber).

I can do this on a form view easily enough:

=Left([fsub_Staff].[Form]![FirstName],3) & Left([fsub_Staff].[Form]![LastName],3) & [fsub_Staff].[Form]![ID]

However, I would really need this to be hard coded back into the underlying database table, consisting of the first, last and autonumber field (as reference).

Any assistance would be appreciated.
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
11-Dec-2008, 08:42 AM #2
I am not sure why they need this reference number, as the Autonumber does the job as far as the database is concerned.
But as you have the job to do, just add the new Reference Number field to the Data Input Form and then use the equivalent VBA version of your Formula in the First and Last Name Fields After Update Event Procedures.
The VBA Version is
me.referencenumber = Left(me.[FirstName],3) & Left(me.[LastName],3) & me.[ID]
where referencenumber is the actual name of your new field.
It needs to be in both fields in case someone changes either field later.

You can also create an update Query to update any current data.
__________________
OBP
I do not give up easily
JoeBlack999's Avatar
Computer Specs
Member with 77 posts.
 
Join Date: May 2008
Experience: Intermediate
11-Dec-2008, 11:09 AM #3
Access 2007 - copy calculated reference number to underlying table
Quote:
Originally Posted by OBP View Post
I am not sure why they need this reference number, as the Autonumber does the job as far as the database is concerned.
But as you have the job to do, just add the new Reference Number field to the Data Input Form and then use the equivalent VBA version of your Formula in the First and Last Name Fields After Update Event Procedures.
The VBA Version is
me.referencenumber = Left(me.[FirstName],3) & Left(me.[LastName],3) & me.[ID]
where referencenumber is the actual name of your new field.
It needs to be in both fields in case someone changes either field later.

You can also create an update Query to update any current data.


I assume its the code builder, option on the afer update event procedure?

Private Sub FirstName_AfterUpdate()
Me.Reference = Left(Me.[FirstName], 3) & Left(Me.[LastName], 3) & Me.[ID]
End Sub


Access spits out some errors, what or where have I goofed up?
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
12-Dec-2008, 06:42 AM #4
Sorry , I missed your reply yesterday, what errors do you get?
You may need to set some Library references to use the VBA code.
JoeBlack999's Avatar
Computer Specs
Member with 77 posts.
 
Join Date: May 2008
Experience: Intermediate
19-Dec-2008, 12:27 PM #5
RE: Access 2007 - copy calculated reference number to underlying table
Quote:
Originally Posted by JoeBlack999 View Post
I assume its the code builder, option on the afer update event procedure?

Private Sub FirstName_AfterUpdate()
Me.Reference = Left(Me.[FirstName], 3) & Left(Me.[LastName], 3) & Me.[ID]
End Sub


Access spits out some errors, what or where have I goofed up?

Sorry for the delay in responding - the code is working - must have not pasted it in correctly - thanks for your help - problem now solved.l
Reply

Tags
2007, access, autonumber, calculated, reference

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:04 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.