Hello,
For some reason I get stuck right on the frist line of code. I am looking for some sample code that allow me to extract data from the database.
Sub UpdateDB()
'Writes records to database
Dim db1 As Database
Dim rs1 As Recordset
dBase = "C:\Documents and Settings\qguan\Desktop\481\SignoffLog"
Set db1 = OpenDatabase(dBase)
Set rs1 = db1.OpenRecordset("Select * from SignoffLog where AnalystSignoffDate = Date() and CheckboxName= """ & mychkbox & """")
If rs1.RecordCount() > 0 Then
MsgBox "Start editing existing record into the database"
With rs1
.Edit
'!CheckboxName = mychkboxname
!ReviewerSignoffDate = Date
!Reviewer = UserId()
.Update
End With
Else
MsgBox "Start adding new record into the database"
With rs1
.AddNew
!CheckboxName = "" 'mychkboxname
!AnalystSignoffDate = Date
!Analyst = UserId()
.Update
End With
End If
db1.Close
Set rs1 = Nothing
Set db1 = Nothing
End Sub
For some reason I get stuck right on the frist line of code. I am looking for some sample code that allow me to extract data from the database.
Sub UpdateDB()
'Writes records to database
Dim db1 As Database
Dim rs1 As Recordset
dBase = "C:\Documents and Settings\qguan\Desktop\481\SignoffLog"
Set db1 = OpenDatabase(dBase)
Set rs1 = db1.OpenRecordset("Select * from SignoffLog where AnalystSignoffDate = Date() and CheckboxName= """ & mychkbox & """")
If rs1.RecordCount() > 0 Then
MsgBox "Start editing existing record into the database"
With rs1
.Edit
'!CheckboxName = mychkboxname
!ReviewerSignoffDate = Date
!Reviewer = UserId()
.Update
End With
Else
MsgBox "Start adding new record into the database"
With rs1
.AddNew
!CheckboxName = "" 'mychkboxname
!AnalystSignoffDate = Date
!Analyst = UserId()
.Update
End With
End If
db1.Close
Set rs1 = Nothing
Set db1 = Nothing
End Sub