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

Use .Update to change record in table

Status
Not open for further replies.

rbehnke

Technical User
Jul 20, 2007
20
US
After an Event, I am trying to Update certain data for a record in a table. here is the code I've been able to come up with so far:


Dim dbsGeneric As Object
Dim rstTM As Object

Set dbsGeneric = CurrentDb
Set rstTM = dbsGeneric.OpenRecordset(“tblTestMatrix”)

rstTM.Sequence = Me.Sequence

rstTM(“Approved”) = True
rstTM.Update

rstTM.Close
dbsGeneric.Close


I could use some help to select the record that I want to Update and to complete the Update process. . . Thanks.

 
You need .Edit

Code:
rstTM.Edit

rstTM.Sequence = Me.Sequence

rstTM("Approved") = True
rstTM.Update

The above will update a single record.
 
You probably want to update a specific record ?
Have a look at the FindFirst method of the DAO.Recordset object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you much for your replies. They will both help.

Yes, I am trying to update a specific record.

Here is the code I've tried:

Dim dbsGeneric As Object
Dim rstTM As Object

Set dbsGeneric = CurrentDb
* Set rstTM = dbsGeneric.OpenRecordset(“tblTestMatrix”)

DoCmd.FindRecord "01.00.000", , True

rstTM.Edit

rstTM(“Approved”) = True
rstTM.Update

rstTM.Close
dbsGeneric.Close

I'm trying to update the record that matches 01.00.000 and set the value of the Approved field to True.

When I run, I get error 3078, which says it can't find the table (on the line I marked with an * above). I've used same code in an AddNew logic and works fine.

Thanks again for your help on this.
 
Did you even try to search the meaning of FindFirst ?
 
Yes, I did, and I will try it again.

Again, thanks for your tips. I'm getting closer.
 
Thanks again for your help in solving this for me.

Both the responses above helped get me closer.

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top