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

Update Table from Form using VBA 1

Status
Not open for further replies.

AKMonkeyboy

IS-IT--Management
Feb 4, 2002
141
US
I have an Acess 2000 DB. In it is a form "FrmContact". That form contains fields "CustID" and "Date". I would like to update a table not bound to this form.

My common fields are:
"ID" (TblCustomers.ID)
and
"CustomerID"(Forms!FrmContact!CustomerID).

I would like to add to the Afterupdate event of Forms!FrmContact!ContactDate a process that updates TblCustomers.Date with the value entered. There are other fields that I wish to update, so I have ruled out running queries for all of this updating. I would like to run it in VBA. I'm not real good with recordset opening and the like, but I think that's the route I will end up taking. Any ideas?

Adam

Give me a fish and I eat. Teach me to fish and I will never be hungry again.
 
I believe I have made the neccessary changes for you to just copy and paste this code right into an AfterUpdate Event. This code will do what you are wanting to do. You need to make sure that you have the Microsoft DAO Library 3.6 marked in your references and to make sure it is placed ahead of the Microsoft Active Data Objects 2.x

Have Fun!!

Dim rst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset("TblCustomers", dbOpenDynaset)

rst.FindFirst "[ID] =" & Me.CustID 'need to find the record you want to update
rst.Edit
rst![Date].Value = Me.Date 'use the name of the field for your date in your table
rst.Update
rst.Close

If you need more help Let me know.
Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
Thanks Dave. I kinda thought it had something to do with recordsetting - but I get frustrated when it comes to that stuff. How the heck you knew that you had to check the DAO library box and move it up is beyond me, but this code ran perfectly. I have learned more on this forum than in the 100 or so odd hours of classes I have taken. Know any good places / sources to study up on this stuff?

I'll share some of my millions with you... when I get some.

Can't thank you enough.

Adam
monkeyboyemail@netzero.net
 

Here are a few good places to get information and sample code. I use to have a site but since I could not aford it (lack of job) I had to let it go. But I do have some sample code if you need or are looking for something particular. Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top