I keep getting the error object required. Can anyone please look at my code and tell my why I'm getting this error?
Private Sub cmdAddRec_Click()
On Error GoTo Err_cmdAddRec_Click
Dim rstFile As New ADODB.Recordset
Dim fld As ADODB.Field
Dim strField As String
rstFile.Open "dbo_tbl_Files", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If IsNull(Me.FileID.Value) Then
'this is new record
rstFile.AddNew
Else
'to stay on the record that was just inserted for editing
rstFile.Find ("FileID=" + Str$(Me.FileID))
End If
rstFile!FileNo = Me.FileNo
rstFile!FileName = Me.FileName
rstFile!Dept = Me.Dept
rstFile!SectID = Me.SectID
rstFile!DateOpened = Me.DateOpened
rstFile!AttyID = Me.AttyID
rstFile!Description = Me.Description
rstFile!Status = Me.Status
rstFile.Update
'this was a new record so update the form value of FileID for edit
If IsNull(rstFile!FileID.Value) <> True Then
Me.FileNo = rstFile!FileID.Value
End If
rstTrans.Close
Set rstFile = Nothing
AddNewRec
'DoCmd.GoToRecord , , acNewRec
Exit_cmdAddRec_Click:
Exit Sub
Err_cmdAddRec_Click:
MsgBox Err.Description
Resume Exit_cmdAddRec_Click
End Sub
Private Sub cmdAddRec_Click()
On Error GoTo Err_cmdAddRec_Click
Dim rstFile As New ADODB.Recordset
Dim fld As ADODB.Field
Dim strField As String
rstFile.Open "dbo_tbl_Files", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If IsNull(Me.FileID.Value) Then
'this is new record
rstFile.AddNew
Else
'to stay on the record that was just inserted for editing
rstFile.Find ("FileID=" + Str$(Me.FileID))
End If
rstFile!FileNo = Me.FileNo
rstFile!FileName = Me.FileName
rstFile!Dept = Me.Dept
rstFile!SectID = Me.SectID
rstFile!DateOpened = Me.DateOpened
rstFile!AttyID = Me.AttyID
rstFile!Description = Me.Description
rstFile!Status = Me.Status
rstFile.Update
'this was a new record so update the form value of FileID for edit
If IsNull(rstFile!FileID.Value) <> True Then
Me.FileNo = rstFile!FileID.Value
End If
rstTrans.Close
Set rstFile = Nothing
AddNewRec
'DoCmd.GoToRecord , , acNewRec
Exit_cmdAddRec_Click:
Exit Sub
Err_cmdAddRec_Click:
MsgBox Err.Description
Resume Exit_cmdAddRec_Click
End Sub