Runtime Error - Opening form based on subform selection
Posted on 2004-08-18
With Access 2000 (an ADP file) and a SQL Server 2000 database...
I have a main Order Form with a subform that shows a data-sheet list of auctions. The subform is based on a view, and the parent/child link is through the field OrderID. I would like for users to be able to click a command button on the main form to open a separate Auction Form that goes to the record of the auction currently selected in the subform. In the Auction Form, auction records are keyed by EbayNum.
The fields in the subform include OrderID (which ties each subform record to the main Order Form), EbayNum, LotNum, and LotDescription. (Note: A given EbayNum value can be associated with more than one OrderID, so it is not used for child/parent relationship here.)
Here is the On_Click event code I am trying to use for the command button, called ViewAuction:
> Private Sub ViewAuction_Click()
> DoCmd.OpenForm "AuctionForm", , , "EbayNum = " & Me.OrderSubform.Form!EbayNum
> End Sub
Upon clicking the command button, I get the following error:
"Run-time error '2757': There was a problem accessing a property or method of the OLE object."
The debugger then highlights the DoCmd line of my code.
Syntactically speaking, I can't find anything wrong with what I'm doing. Does anyone have any insights for me?