Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveForm in function called by On Current (Access 2000)

Status
Not open for further replies.

MackC

Programmer
Nov 8, 2001
23
0
0
US
I'm having a problem with a function that is called from the On Current event of several different forms. The purpose of the function is to record the ID number of each record, so that I have this value available to use in an audit trail program when I delete a record. This is the code:
Function StoreIDs()
Dim frm As Form
Set frm = Screen.ActiveForm
strPrevID = strCurrID
strCurrID = frm!RecordID
End Function

This code works fine as long as I'm moving from record to record within a form. But when I close the form and reopen it, I get the following error message when the program reaches the ActiveForm statement: "Error 2475 You entered an expression that requires a form to be the active window
 
Screen.Activeform is prone to error. I would pass the currently open form as an object to your procedure

Function StoreIDs(byref CurrentForm as Form)

Set frm = CurrentForm
strPrevID = strCurrID
strCurrID = frm!RecordID

End Function

Your forms that call the procedure is would call it like

Call Storeid(me)



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top