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

I'm trying to use the code below, w

Status
Not open for further replies.

AtlWill

Instructor
Mar 9, 2003
2
US
I'm trying to use the code below, which is from the book "Access 2002 Visual Basic for Applications", and I get a Run time error 2450..can't find the form. The form is spelled correct, but it still doesn't work. I've verified that the DAO reference was selected.

Private Sub ShowRecord_Click()
' Find the selected record, then close the dialog box.

Dim rst As DAO.Recordset

' Store the recordset for the Subscribers form.
Set rst = Forms!Subscribers.RecordsetClone

' Locate the record for the selected subscriber.
rst.FindFirst "SubscriberID = " & List0

' Set the form's Bookmark property to move to the record.
Forms!Subscribers.Bookmark = rst.Bookmark

' Close the dialog box.
DoCmd.Close acForm, "GoToRecordDialog"

End Sub

Any help would be a life saver.
 
AtlWill:

Is the Subscribers form already open? What triggers the dialog box to appear?

Not quite sure what you mean by: I've verified that the DAO reference was selected.

Of course I've just returned from vacation, so that might have something to do with the cobwebs in my head. [smile]

Vic
 
Vic

The subsciber form is not open. I am trying to open the form with the record that is selected from the list box.

I mentioned the DAO refence library because it was mentioned as a fix in another thread.

Thanks
 
AtlWill

Your sub won't work as written unless the Subscriber form is already open.

If you want the Subscriber form to open and show only the selected record, then you need to code the Click event something like this:

DoCmd.OpenForm ,,,[Record Source fieldname] = Me.[controlname]

Once you've opened the Subscriber form, the remaining code in the DoCmd.Close Form "GoToRecordDialog" will not execute until the Subscriber form is closed. So instead, put in the OnOpen event of the Subscriber form the following code:

DoCmd.Close acForm, "GoToRecordDialog", acSaveNo

However, if you want the form to open at the selected record but still be able to see other records, then the logic and coding is a bit more involved.

HTH,

Vic



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top