MarkWaddington
Programmer
Hi,
I am using the following code to try and update a table named "staff" with the current username:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrorHandler
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Staff", dbOpenDynaset)
.AddNew
.Fields("StaffName"
= CurrentUser()
.Update
ExitHere:
Set rs = Nothing
Set db = Nothing
Exit Sub
ErrorHandler:
MsgBox "A " & Err.Number & " error has occurred. Please contact the admin."
Resume ExitHere
End Sub
However when the code runs I get the following error, "Compile Error - user defined type not defined"
And the line "Dim db As Database" is highlighted in yellow. I figure I have to tell the database this defined type, but I don't know how.
I am still trying to get to grips with VB so please answer in simple language for me!
Thanks in advance,
Mark Waddington.
I am using the following code to try and update a table named "staff" with the current username:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrorHandler
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Staff", dbOpenDynaset)
.AddNew
.Fields("StaffName"
.Update
ExitHere:
Set rs = Nothing
Set db = Nothing
Exit Sub
ErrorHandler:
MsgBox "A " & Err.Number & " error has occurred. Please contact the admin."
Resume ExitHere
End Sub
However when the code runs I get the following error, "Compile Error - user defined type not defined"
And the line "Dim db As Database" is highlighted in yellow. I figure I have to tell the database this defined type, but I don't know how.
I am still trying to get to grips with VB so please answer in simple language for me!
Thanks in advance,
Mark Waddington.