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

Change values in a table

Status
Not open for further replies.

tweaked2005

Technical User
Jun 21, 2005
20
US
I'm using MS Access, and programming in VBA. I have a form, and want the code to run when I open the form, so I've created an event for on Open. I'm using the code below. Baseically, I want it to evaluate each record, and populate my comment field with "new" if the condition is true. This is not working for me, so any help is greatly appreciated.
Code:
Private Sub Form_Open (Cancel As Integer)
  Dim db1 As DAO.Database, rcd1 As DAO.Recordset
  Set db1 = Current db()
  Set rcd1 = db1.OpenRecordset("testTable",dbOpenDynaset)
  If Not rcd.EOF Then
    If Date - rcd![startDate] < 50 Then
      rcd1.Edit
      rcd1![Comment/Observation] = "New"
    End If
  End If
End Sub
 
You wanted something like this ?
DoCmd.RunSQL "UPDATE testTable SET [Comment/Observation]='New' WHERE (Date()-startDate)<50"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top