DoCmd.GoToRecord question

  • Thread starter Slez via AccessMonster.com
  • 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
 
J

Jeff Boyce

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
 
S

Slez via AccessMonster.com

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
 

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

Similar Threads


Top