Access crashes when opening form

D

Dan Wieland

When launching a form, access closes and asks to send an error report to
Microsoft.

I have the following code in the On Load event of the form:
DoCmd.GoToRecord acDataForm, "frmInvoiceMainLime", acNewRec
Me.txtPurchaseOrder = "hello"

PurchaseOrder is a bound textbox control on frmInvoiceMainLime.
If I comment out either line, Access is fine, and does not crash. If I have
both lines in, Access crashes everytime.
Anything wrong with using the GoToRecord method in a form's On Load event?
Or is there anything wrong with setting the value of a bound control during
the On Load event?

I suspected that my database is possibly corrupt, because this is not making
any sense. I made sure the Name Autocorrect boxes are unchecked on the
Tools, Options, General tab. I've Compacted and Repaired. I've also tried
decompiling. No luck.

Any ideas? Thanks in advance.
Dan
 
T

tina

well, i'm wondering if your form is corrupted. you might want to open a new
db, turn off Name Autocorrect, import all your db objects *except* that
particular form, and build the form from scratch.

i tested your code on a form's Load event (in an A2000 database built and
running in A2003), including setting a bound control's value, using each of
the following in turn, as

DoCmd.GoToRecord acDataForm, "FormName", acNewRec

and

DoCmd.GoToRecord , , acNewRec
' note that when the code is running in the active form
' you can leave the first two arguments blank.

and

DoCmd.RunCommand acCmdRecordsGoToNew
' the command i usually use.

all three variations of the code ran fine, so it would seem that the problem
is not with your code.

hth
 
D

Dan Wieland

Thanks Tina. Appreciate you confirming the code. Looks like I'm going to
have to rebuild that form from scratch. grrrr.
 
T

tina

oh, bummer. good luck with it! :)


Dan Wieland said:
Thanks Tina. Appreciate you confirming the code. Looks like I'm going to
have to rebuild that form from scratch. grrrr.
 
Top