DoCmd.GoToRecord question

  • Thread starter Thread starter Slez via AccessMonster.com
  • Start date Start date
S

Slez via AccessMonster.com

I have a command button that opens frmNoBidMain, which contains a subform
called frmNoBid. In the open event of frmNoBid is the following code:

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord acDataForm, "frmNoBid", acNewRec
End Sub

My intent is that when you open frmNoBidMain, it takes you to the new record
in frmNoBid.

When I click the command button, I get an error message: Run-time error
'2489'; The object 'frmNoBid' isn't open.
Debugging highlights my DoCmd line. Clicking Help doesn't yield anything.

What is wrong with my code?
Thanks!
Slez
 
Not sure why this is posted in the tablesdbdesign newsgroup ...?

If your subform is actually in a subform control on your main form, you
don't need to "open" it. Using a main form/sub-form design will let the
sub-form find any/all records related to the record in the main form.

By the way, if the main form does not contain a record, and the sub-form is
supposed to hold records that "belong to" the main form's record, then
opening the sub-form (without a main form record) should cause an error ...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Sorry...meant to post in Forms Programming!

Jeff said:
Not sure why this is posted in the tablesdbdesign newsgroup ...?

If your subform is actually in a subform control on your main form, you
don't need to "open" it. Using a main form/sub-form design will let the
sub-form find any/all records related to the record in the main form.

By the way, if the main form does not contain a record, and the sub-form is
supposed to hold records that "belong to" the main form's record, then
opening the sub-form (without a main form record) should cause an error ...

Regards

Jeff Boyce
Microsoft Office/Access MVP
I have a command button that opens frmNoBidMain, which contains a subform
called frmNoBid. In the open event of frmNoBid is the following code:
[quoted text clipped - 14 lines]
Thanks!
Slez
 
Back
Top