my problem is i want to save a date from label in vb to field in ms access but i do not know that problem with my coding, the error appear is run-time error 91 object variable or with block variable not set, can anyone check my coding?
Dim Con As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Private Sub cmdfind_Click()
Dim search As String
search = txtfind.Text
Call OpenConnection
With Rs
.ActiveConnection = Con
.CursorType = adOpenDynamic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open "SELECT * FROM STUDENTS where [reg] like" & "'" & search & "'", Con, adOpenStatic, adLockOptimistic
End With
If Rs.EOF = True Or Rs.BOF = True Then
MsgBox "PLEASE REGISTER YOUR NAME TO WARDEN"
Else
txtNAME = Rs.Fields("NAME")
txtMATRIX = Rs.Fields("MATRIX NO")
txtIC = Rs.Fields("IC NO")
txtCONT = Rs.Fields("CONTACT NO")
txtROOM = Rs.Fields("ROOM NO")
lblTMEOUT.Caption = Now
End If
Set Rs = Nothing
Set Con = Nothing
cmdfind.Visible = False
txtfind.Visible = False
Label1.Visible = False
frminfo.Visible = True
End Sub
Private Sub OpenConnection()
Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Fairus\Documents\docklet\my work\project\HOSTEL STUDENT.mdb;Persist Security Info=False"
Con.Open
End Sub
Private Sub cmdrecord_Click()
STUDENT.Recordset.Update
STUDENT.Recordset.Fields("TIME OUT") = lblTMEOUT
End Sub