473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Access VBA - lookup and alter records problems

G'Day Guys im a newbie to access.

I'm trying to implement a new database at work.
I've tried for hours looking through technical sites and forums and can't find a similar problem already posted.

What Im trying to achieve is, as the end user is filling out a form ie.[Build Checklist] it will update records in other tables in the database. The example in the psudocode posted below is trying to match a record from the database to the input data in the form after the form updates it then alters existing records to bring them up to date

Expand|Select|Wrap|Line Numbers
  1. Private Sub Server_Serial_AfterUpdate()
  2. loop through [Hardware Assets] records
  3.  
  4. If [Hardware Assets]![SerialNumber] = [Build Checklist]![GWSerialNumber] Then
  5.     [Hardware Assets]![LastHandledBy] = [Build Checklist]![GWBuildBy]
  6.  
  7. End If
  8. end loop
  9.  
If someone could give me some ideas as to the sort of functions I should be using to search and alter the record with VBA or any other method would be appreciated

Thanks

Griff84
May 29 '07 #1
3 2920
Lysander
344 Expert 100+
G'Day Guys im a newbie to access.

I'm trying to implement a new database at work.
I've tried for hours looking through technical sites and forums and can't find a similar problem already posted.

What Im trying to achieve is, as the end user is filling out a form ie.[Build Checklist] it will update records in other tables in the database. The example in the psudocode posted below is trying to match a record from the database to the input data in the form after the form updates it then alters existing records to bring them up to date

Expand|Select|Wrap|Line Numbers
  1. Private Sub Server_Serial_AfterUpdate()
  2. loop through [Hardware Assets] records
  3.  
  4. If [Hardware Assets]![SerialNumber] = [Build Checklist]![GWSerialNumber] Then
  5.     [Hardware Assets]![LastHandledBy] = [Build Checklist]![GWBuildBy]
  6.  
  7. End If
  8. end loop
  9.  
If someone could give me some ideas as to the sort of functions I should be using to search and alter the record with VBA or any other method would be appreciated

Thanks

Griff84
Not sure exactly what you want to do, but here are some ideas.

Base your form (build checklist) on a query linking 'Hardware Assets' to 'Build Checklist' tables and have lasthandledby as a hidden control on the form. Then in code, as the serial number is updated, change lasthandledby.

If 'Build Checklist' is not a table, or you can't link it to 'Hardware Assets' then in the after_update event of either the control or the form, you can run something like this.

docmd.runsql "UPDATE [Hardware Assets] SET [LastHandledBy] = '" & GWBuildBy & "' WHERE SerialNumber=" & GWSerialNumber & ";"

This assumes GWSerialNumber and GWBuildBy are controls on the form and that GWBuildBy is a string, the other a number.
May 29 '07 #2
docmd.runsql "UPDATE [Hardware Assets] SET [LastHandledBy] = '" & GWBuildBy & "' WHERE SerialNumber=" & GWSerialNumber & ";"
It took a little fiddling but the above code worked like a charm sorry for the late reply I only work here once a week
Jun 5 '07 #3
Lysander
344 Expert 100+
It took a little fiddling but the above code worked like a charm sorry for the late reply I only work here once a week
Glad it work, pleased to be of help
Jun 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Dan Edwards | last post by:
Hi about 2 months ago I had trouble with alter table on large tables blocking all database activity and started a thread on this list called "alter table blocks other tables!" I tried to resolve...
12
by: Mike MacSween | last post by:
Sorry if this is a bit off topic, but I can't seem to find a 'remote control' newsgroup on my news server. And anyway I know Tony has some experience of this. The app is split FE/BE. I'd like...
30
by: Andante.in.Blue | last post by:
I just browsed through some of my Access links when I came across the Ten Commandments of Access (http://www.mvps.org/access/tencommandments.htm). Some of the points I heartily agree with (and...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
17
by: DaveG | last post by:
Hi all I am planning on writing a stock and accounts program for the family business, I understand this is likely to take close to 2 years to accomplish. The stock is likely to run into over a...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
9
by: Michael M. | last post by:
Hi all, I would like to know how to access the NT/2000/XP/2003 Name cache; what I mean by this is: Open a Command Prompt and.., C:\> C:\>IPCONFIG /DISPLAYDNS
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.