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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnCurrent event on form

Status
Not open for further replies.

BrockLanders

Programmer
Dec 12, 2002
89
US
Hi, I'm trying to do a simple OnCurrent event using Access 2000, but to no avail. The code is suppossed to pop up a messagebox if the current record is new. I have the below code saved as a module:
Code:
Sub NewRecordMark(frm As Form)
    Dim intnewrec As Integer
    
    intnewrec = frm.NewRecord
    If intnewrec = True Then
        MsgBox "You're in a new record."
    End If
End Sub
I then created a RunCode macro with NewRecordMark("frmOrders") in the Function Name box of the macro builder. Then I set the OnCurrent event of frmOrders to my macro.
When the form is opened I get the error: "The expression you entered has a function name that Access can't find."
It seems like just a simple syntax error, but I can't figure it out.
Thanks in advance for any help
 
Why use a macro?

Enter the following into the on current event procedure:

[tt]if me.newrecord then
msgbox "new record"
end if[/tt]

I think the error might be caused by your sub not being a public sub in a general module - and that it should be a public function, not a sub - but use the event procedure of the on current event in stead.

Roy-Vidar
 
That worked! I used your suggestion and didn't use a macro at all. You were right about the public function vs. sub.

Thanks Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top