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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing tables with VB code?

Status
Not open for further replies.
Mar 29, 2006
24
US
Hi all!

I've been bugging you guys for the past few days. :) I didn't see anything when I searched, but does anyone know a good little summary (preferably w/ an example or two) on how to reference tables with VB code? For that matter, do you think I can do what I want to do without resorting to the method I'm thinking of?

Here's a simple example of what I want to do: I have a table with the following fields

Customer ID, Customer Name, Account type, Account Balance

I also have a table with the following

Account type, Monthly Credit

Ideally, what I want to do is create a form that will let me push a button once per month, go through my list of customers, and add the appropriate amount of "monthly credit" to their "account balance," based on their account type.

Thanks everyone!
 
This is something you could do with an update query. Have a look at it in the query builder of access.

Pampers [afro]
There is only one way to change a diaper - fast
 
Create a query with both tables. They should be connected via AccountType. Then in the first grid, bring down the AccountBalance. Change the query to an update and where it says Update To put:

[AccountBalance]+[MonthlyCredit]
 
Thanks guys, this looks like it will work. Now it's just mucking with the guts of it.
 
realize though that storing a calculated field usually breaks normalization rules. Read the link below for additional details.

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top