Re: moving a main form and subform to a specific subform record
- From: Marshall Barton <marshbarton@xxxxxxxxxx>
- Date: Thu, 23 Nov 2006 13:58:03 -0600
DawnTreader wrote:
i have a main form with a subform that contains data that i want to search
and goto a specific record. i created a combo find box through the wizard on
a form based on the table that creates my subform and then tried copying and
pasting to the form i really want it on, but the combo box does nothing.
i have a site table that has a one to many relationship with the products
table.
SiteTable
SITEID
SITEADDRESS
ProductsTable
SITEID
PRODUCTID
SERIALNUMBER
the site ID is on the main form and sub form. the mainform is where i need
to place the combo box to find the serial number of the product and have the
mainform and subform move to that product record. how do i do this?
i tried this code:
Private Sub Combo46_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.subfrmtblProductList.Form.Recordset.Clone
rs.FindFirst "[ProductID] = " & Str(Nz(Me![Combo46], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
the subfrmtblProductList is the name of the subform, but the idea i had
doesnt work. do i need to put references to the subform anywhere else? or is
there another approach i need to take when creating this combo box?
"Doesn't work" is not much of a clue about what's happening.
I think you are confusing form and subform bookmarks and
mixing DAO and ADO methods. If you're using DAO, try this:
Private Sub Combo46_AfterUpdate()
' Find the record that matches the control.
Dim rs As DAO.Recordset
Set rs = Me.subfrmtblProductList.Form.RecordsetClone
rs.FindFirst "[ProductID] = " & Str(Nz(Me![Combo46], 0))
If Not rs.NoMatch Then
Me.subfrmtblProductList.Form.Bookmark = rs.Bookmark
End If
End Sub
Not 100% sure, but I think the ADO equivalent might be:
Private Sub Combo46_AfterUpdate()
' Find the record that matches the control.
Dim rs As ADODB.Recordset
Set rs = Me.subfrmtblProductList.Form.Recordset.Clone
rs.Find "[ProductID] = " & Str(Nz(Me![Combo46], 0))
If Not rs.EOF Then
Me.subfrmtblProductList.Form.Bookmark = rs.Bookmark
End If
End Sub
--
Marsh
MVP [MS Access]
.
- Follow-Ups:
- Re: moving a main form and subform to a specific subform record
- From: DawnTreader
- Re: moving a main form and subform to a specific subform record
- From: DawnTreader
- Re: moving a main form and subform to a specific subform record
- Prev by Date: Different results with opening form with docmd.
- Next by Date: Re: Different results with opening form with docmd.
- Previous by thread: RE: moving a main form and subform to a specific subform record
- Next by thread: Re: moving a main form and subform to a specific subform record
- Index(es):
Relevant Pages
|
Loading