Form Open Error Message

D

Dinamo/Pistons

I added three new fields to a form and now I get the following error:
The expression On Open you entered as the event property setting produced
the following error: return without GoSub

Well I did not change the On Open event procedure.. here it is:
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
Me.subFormRepeatCalls.Enabled = False
End Sub

Interesting enough after I open and close the event procedure, I can open
the form without problems. If I exit the database I get the same error. I
deleted the fields, but I am still getting the same error

PLEASE HELP
 
D

Daryl S

Dinamo/Pistons -

I would search (Find) your whole project for any 'Return' statements.

I would also compact/repair your database and re-compile it.

It may not be in the Open method of the form you are looking at, so look
everywhere.
 
M

mie via AccessMonster.com

Try recompile your code. Select All, Cut and Paste, Debug>Compile Database.

or maybe some of your procedure missing "Exit Sub".
 
B

BruceM via AccessMonster.com

For one thing, the Open event is too soon to work with the recordset, as it
has not yet been loaded. The Load event would be the place for DoCmd.
GoToRecord , , acNewRec (or Me.Recordset.AddNew). Other than that, try
adding Option Explicit below Option Compare Database for each code module,
then compile the code. To turn on that option (as you should anyhow), in the
VBA editor go to Tools >> Options >> General tab, and check Require Variable
Declaration (Access 2003 and earlier; not sure where it is in later versions).


Why disable the subform in the Load event? Why not just set it on the
Property Sheet? You can change it through code later, if you want.

What do you mean by "open and close the event procedure"? What fields did
you delete?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top