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

On form open, expression has invalid reference

Status
Not open for further replies.

accesser2

Technical User
Jan 15, 2004
8
US
Hey there,

I just put the following code:

DoCmd.GoToRecord , , acLast

in the On Open event of my form, which has 2 subforms. The following error message appears when the form now opens:

"You entered an expression that has an invalid reference to the property Form/Report." But, after clicking the OK on the msgbox, the form opens to the last record.

Is this a simple fix?

Thanks
 
Hi,

It sounds like this error is being caused by something else.

The DoCmd line you posted doesn't contain any reference to a form or report property. It could be an error in one of your subforms.

Have you debugged the code and stepped through it, a line at a time to find out where the error is occurring?

Dean.
 
Thanks for responding Dean,

I've compiled the code, and found no problems. The form and it's 2 subforms work fine without the go to last record code. I just don't like having the form open to the first record. This is very strange...

The msg that appears just has an OK button, not a debug button. How can I debug this best?

Thanks,

Arnold
 
Hi,

You can debug this by putting a breakpoint in the first line of the OnOpen Sub, by either presaing F9 at that line or clicking the left hand margin. Then step through the code line-by-line by pressing F8 once in debug mode.

An easier way to get straight to the error is to add a watch in the VB editor: Debug|Add Watch...

In the Add Watch Dialog:

1) Type Err<>0 for the expression
2) Change procedure and module to (All Procedures/Modules)
3) Select Break When Value Is True for the Watch Type

Break mode should go directly to the line that first causes an error.

HTH.

Dean :)
 
Thanks Dean,

Your help really helped. I guess if I'm going to continue my quest into VBA coding, I'll need to know how to debug--I'm sure I have lots of bugs.

This particular bug was in the oncurrent event. I had put generic error checking in; but not specific. In actuality, the form wasn't liking the fact that I was trying to do some things with the subforms that were not yet bound. I'm building in functionality to turn on and off the parent/child linking to allow users to view subform data separately from the main form.

Thanks again,

Arnold
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top