Something weird is going on. I spent hours tonight building a database and everything was hunky dory... went to watch a move... then came back and the database wouldn't even open. I was getting a fatal system error. The system gave me a chance to back up the database and then it tried to compact it. But it still couldn't open the database.
So I created a new database and imported all the objects - tables, forms, modules and macros.
It seemed to be working fine but when I try to run code that creates an audit log, the system is giving an error that a form called frmInclExclSection1 does not exist. But it does, and so does the Key field that i've specified.
The code is trying to write to a history table... I got the code from someone on this forum actually, and I know it works. WHen it gets to the line of code with all the *****'s it bombs saying that the form doesn't exist. argh..!
Public Function basAddHist(Hist As String, frm As String, MyKeyName As String, Optional MyCtrl As Control)
Dim dbs As DAO.Database
Dim tblHistTable As DAO.Recordset
Set dbs = CurrentDb
Set tblHistTable = dbs.OpenRecordset(Hist, dbOpenDynaset)
!mykey = Forms(frm).Controls(MyKeyName) *****
!MyKeyName = MyKeyName
!frmName = frm
!FldName = MyCtrl.ControlSource
!dtChg = Now()
!UserId = Environ("Username") 'Orlando's Way
'!UserId = CurrentUser() 'Mike's way, example of current user would be Admin
!OldVal = MyCtrl.OldValue
!NewVal = MyCtrl