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!

please help with recordset code

Status
Not open for further replies.

burgesse

IS-IT--Management
May 29, 2002
7
US
When I try to execute this code, I get en "Error 91, object variabe or with block not set.

The purpose of the code is to update a record in a table, based on a match of a field on a form. The code will be executed from a command button.

Option Compare Database

Dim MachineNames As Object
Dim RST As Recordset
Dim QDF As QueryDef
Dim STRSQL As String
Dim DB As Database

Option Explicit


Private Sub Command9_Click()

Set MachineNames = Forms![Laptops Users]![laptop history subform].Form![machine_name]
[red]Set RST = DB.OpenRecordset("machine name listing")[/red]
STRSQL = ("UPDATE [RST] SET [RST].Used = NO WHERE [RST]![Machine Name]") = MachineNames
DB.Execute STRSQL

End Sub


 
you must first open your database

Use this before the set RST... line:

set db = OpenDatabase("database path")

 
IN DAO,u must first open the database using openDatabase(database path) and use db.openrecordset() Srinivasa Raghavan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top