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

Autoexec Sub on

Status
Not open for further replies.

1510982

Programmer
Feb 17, 2002
57
SI
Hi.
Let's say I've got three numeric fields from database on each form and one for sum, which is calculated by one Sub. Now I want to know if it's possible to run Sub each time you change record and ofcourse on the beginning (enter). Thank you for your answer.
 
Hi!

Use the Form_Current event procedure. This one runs every time a different record is displayed on the form.

hth
Jeff Bridgham
bridgham@purdue.edu
 
TNX, it works very well. Except one thing. When I get to the last record to add a new one, it tries to calculate some fields that don't exist and returns Invalide use of Null. How could I fix that. Like this:

If newfield = FALSE Then
calculate()
End If

How to check if the last one is indeed the new field? Thanks for answer!
 
Hi!

Try If IsNull(YourTextBoxNeededForCalcs) = True Then
etc.

hth
Jeff Bridgham
bridgham@purdue.edu
 
I've found it. At first I wanted to DCount all records + 1 and check if currentrecord is equal. But there's a function NewRecord, which returns 1 if it's new and 0 if it isn't. Neat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top