A
Adam
Hi all ,
I have the following code that writes any changes a recordset to another
table so that I can track changes etc. For some reason it is coming up with
the above error. Does anyone know how I can fix this ?
Here's the code:
'
' AUDIT PROCEDURE BELOW
'
Call fOSUserName
'
Dim mydb As DAO.Database
Dim indata As DAO.Recordset
Dim Ctl As Control
'
Set mydb = CurrentDb()
'
Set indata = mydb.OpenRecordset("tblDevMain_Audit")
indata.AddNew
indata("auditdate") = Now()
indata("auditusername") = fOSUserName
' Not Needed as if it is already an autonumber field
' and the AddNew will automatically increment
' indata!Counter = Forms!form1!Counter
' This is bulldozer coding as the form contains
' all sorts of control types
On Error Resume Next
For Each Ctl In Me '<- current form
' this will error if your tblOfficers_Audit table doesn't
' have a field called the same as a Control, or the
' Control doesn't have a Value Property, and so skip
indata(Ctl.NAME) = Ctl.Value
' so look at the next Control and try again
Next Ctl
' reset Error Trap
On Error GoTo 0
indata.Update
'
indata.Close
Set indata = Nothing
Set mydb = Nothing
'
cheers,
Adam
I have the following code that writes any changes a recordset to another
table so that I can track changes etc. For some reason it is coming up with
the above error. Does anyone know how I can fix this ?
Here's the code:
'
' AUDIT PROCEDURE BELOW
'
Call fOSUserName
'
Dim mydb As DAO.Database
Dim indata As DAO.Recordset
Dim Ctl As Control
'
Set mydb = CurrentDb()
'
Set indata = mydb.OpenRecordset("tblDevMain_Audit")
indata.AddNew
indata("auditdate") = Now()
indata("auditusername") = fOSUserName
' Not Needed as if it is already an autonumber field
' and the AddNew will automatically increment
' indata!Counter = Forms!form1!Counter
' This is bulldozer coding as the form contains
' all sorts of control types
On Error Resume Next
For Each Ctl In Me '<- current form
' this will error if your tblOfficers_Audit table doesn't
' have a field called the same as a Control, or the
' Control doesn't have a Value Property, and so skip
indata(Ctl.NAME) = Ctl.Value
' so look at the next Control and try again
Next Ctl
' reset Error Trap
On Error GoTo 0
indata.Update
'
indata.Close
Set indata = Nothing
Set mydb = Nothing
'
cheers,
Adam