Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Change Table Field Value
Harvey Abernathy 
     
4 years ago
I need VBA Code to loop through all records in a table and change the value of a specific field based on criteria of other field(s). For example

If field1 = x or field2 = x then change field3 to y.

I get monthly excel statements with phone record data that I am importing to access and I need to add a customerID and an invoiceID to the records based on the phone numbers. There are about 6k rows in the excel spreadsheet to import each month.
Adam Schwanz  @Reply  
           
4 years ago
You need a recordset then. I think they begin covering those in Access Developer 16
Scott Axton  @Reply  
        
4 years ago
Harvey Abernathy OP  @Reply  
     
4 years ago
I would like to use Loops but I need the syntax to reference the specific table.record.field(s)
Scott Axton  @Reply  
        
4 years ago
That is where going through the courses come into play.

We are here to help out, not to just write individuals code.  We're glad to point you in the right direction but at some point...

If you want someone to do the work for you there is always the AccessDev.NET.
There are developers listed there that can help for a fee.
Harvey Abernathy OP  @Reply  
     
4 years ago
Scott, thanks for your help. The TechHelp videos have been very helpful and are a wealth of information, but I could not find one that helped me with this specific issue. There are several videos using forms so maybe I'll just change my logic and not try to modify the temp excel imported table.
Alex Hedley  @Reply  
            
4 years ago
Why can't you not just do some VLOOKUP/XLOOKUPS for the values in excel first
Then do an import
Kevin Yip  @Reply  
     
4 years ago
This may be accomplished with just an update query (no VBA needed) with the right criteria and relationships (if needed).  Sample SQL:

UPDATE PhoneRecT
SET CustomerID = DLookup("CustomerID", "CustomerT", "PhoneNum = '" & PhoneNum & "'") & ""
WHERE CustomerID Is Null
Harvey Abernathy OP  @Reply  
     
4 years ago
The finished table in access needs to include the customerID and the InvoiceID that are created in access. The call data that comes from a 3rd party excel sheet only has info related to the phone number. Importing the detail data associated with the phone number is easy but I need to insert the InvoiceID & CustomerID before I merge it into the access Invoice table so that the data can be referenced per customer and then per Invoice. Thank all of you very much for your comments as they have been helpful.
Kevin Robertson  @Reply  
          
4 years ago
Richard Rost  @Reply  
          
4 years ago
Yeah, depending on the specifics, you can probably get away with a bunch of Update Queries
Harvey Abernathy OP  @Reply  
     
4 years ago
Wow, I did not realize what can be accomplished with DoCmd.RunSQL commands. I was able to combine all of the queries I needed into these commands and get the project working.

Thank all of you so much for your help.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 6:27:46 AM. PLT: 0s