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

Return without GoSub

Status
Not open for further replies.

postermmxvicom

Programmer
Jun 25, 2007
114
US
I am getting the following errors when I open a form:

"the expression On Load you entered as the event property setting produced the following error:Return without Gosub."

"the expression On Current you entered as the event property setting produced the following error:Return without Gosub."

This form was working fine. I made some changes to it. What I did was I added some fields to an underlying table, so I added the appropriate controls to this form for data entry. Even after I made these changes, everything was working fine last night.

This morning, I open it up and bam! Plus I don't get this message every time. Here is the OnLoad and OnCurrent for the form:

Code:
 Private Sub Form_Current()

Me.LotNumber.DefaultValue = DMax("LotNumber", "Lot") + 1


End Sub

Private Sub Form_Load()

Me.LotNumber.DefaultValue = DMax("LotNumber", "Lot") + 1


End Sub


Any ideas?

PS. I have a back up version of this form, before I made yesterday's changes and it is fine.

Also, when I was making the changes access was acting goofy. In particular, the properties box was not auto updating when I selected a new control. It would stay wherever it was, I had to manually select from the drop down which control I was editing. And then when I did select a new control, I still had to 'refresh' it to see the properties of the control I had just selected.
 
Never mind. I got it. Of course, right after I post. (Honestly I did try to figure this out before I posted, google etc)

But, for posterity:


What I failed to mention is that I *replaced* one control with three, and left in the code that was for that control's onfocus. Apparently, this made access and VB cranky, causing it to throw out an error on the *next* sub that it came across, not the one with the offending reference.

Thank you. Your forum is so great, it scares answers out of problems before anyone has a chance to reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top