Start New Discussion within our Software Development Community

the error say's object required
the error point out on CheckInsql where the code to insert data

Dim CheckIncon As ADODB.Connection
Dim CheckInrs As ADODB.Recordset
Dim CheckIncmd As ADODB.Command
Dim CheckInsql As String

Private Sub CheckInConToDB()

Set CheckIncon = New ADODB.Connection

CheckIncon.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;" _
& "Data Source = D:\HMS\Data\dbHMS.mdb"
CheckIncon.Open

End Sub

Private Sub CheckInNewRecSet()

Set CheckInrs = New ADODB.Recordset
CheckInrs.CursorLocation = adUseClient
CheckInrs.Open CheckInsql, CheckIncon, adOpenStatic, adCmdText

End Sub

Private Sub cmdcancel_Click()
frmMain.Enabled = True
frmMain.Show
Unload Me
End Sub

Private Sub cmdCheckIn_Click()

CheckInsql = "Insert into Customer(CustLN,CustFN,CustMN,Address,Email,TelNo,MobileNo,FaxNo)" & _
"values(" & "'" & txtLN.Text & "'," & "'" & txtFN.Text & "'," & "'" & txtMN.Text & "'" & "'" & txtAddress.Text & "'," & _
"'" & txtEmail.Text & "'," & "'" & txtTel.Text & "'," & _
"'" & txtMobile.Text & "'" & "'" & txtFax.Text & "')"

Call CheckInConToDB
Call CheckInNewRecSet

CheckInsql = "Update Customer Set" & _
"[CustLN] = '" & txtLN.Text & "'" & _
"[CustFN] = '" & txtFN.Text & "'" & _
"[CustMN] = '" & txtMN.Text & "'" & _
"[Address] = '" & txtAddress.Text & "'" & _
"[Email] = '" & txtEmail.Text & "'" & _
"[TelNo] = '" & txtTel.Text & "'" & _
"[MobileNo] = '" & txtMobile.Text & "'" & _
"[FaxNo] = '" & txtFax.Text & "'" & _
"Where [CustomerID] Like '" & txtCustID & "'"

Call CheckInConToDB
Call CheckInNewRecSet

End Sub

You have not set a reference o the recordset -

Set CheckInRs = New ADODB.RecordSet

Try this and your problem should be solved.

This article has been dead for over six months. Start a new discussion instead.