Hi, EasyGeeza.
Sorry guys code as follows
Posting the code would certainly help us to figure out how it may be fixed.
Regards,
Fish
Private Sub cmdRemoveFromHire_Click()
'DB connection and Recordset objects
Dim rsItemToMove As ADODB.Recordset
Set DBConn = New ADODB.Connection
Set rsItemToMove = New ADODB.Recordset
' vars for manipulation
Dim LineSelection() As Boolean
Dim CarSelector
Dim ContactName As String
Dim CarMake As String
Dim CarModel As String
Dim CarID As Integer
Dim ContactID As Integer
Dim test As String
If Me.subfrmCarsField.Form.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If
' SQL command obect and instance
Dim SQLCommand As ADODB.Command
Set SQLCommand = New ADODB.Command
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentProject.Path & CurrentProject.Connection
' database connection patch and source detail declared globally
DBConn.Open strConnection 'open DB connection using path
Me.subfrmCarsField.Form.RecordsetClone.MoveFirst 'clone the subforms query results from form selection
'into cloned recordset and move to first position
' loop through rows returned in subform cloned record set and pass to rsSubFormRows RS
While Me.subfrmCarsField.Form.RecordsetClone.EOF = False ' while recordsetclone not at the end of the file
CarID = Me.subfrmCarsField.Form.RecordsetClone("CarID")
ContactID = Me.subfrmCarsField.Form.RecordsetClone("ContactID" )
CarSelector = Me.subfrmCarsField.Form.RecordsetClone("CarSeletor ")
If CarSelector = True Then ' if row selected from form
SQLCommand.ActiveConnection = DBConn ' assign the command object to the relevant connection
'you are about to update/execute so it knows which
' DB connection its dealing with
' put the command SQL string into the object ready for execution / update of table
SQLCommand.CommandText = "UPDATE tblCars SET ContactID = 0 WHERE CarID=" & CarID ' remove person from car
SQLCommand.Execute 'perform above SQL statement
SQLCommand.CommandText = "UPDATE tblCars SET CarSeletor = False" 'reset tickbok
SQLCommand.Execute 'perform above SQL statement
End If
Me.subfrmCarsField.Form.RecordsetClone.MoveNext
Wend
subfrmCarsField.Requery 'refreshes data (from a qryCars) in subform using primary key ContactID feild
subfrmCarsOffHireField.Requery
'refresh both subforms query after table alterations above
End Sub