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
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