Open form B and select it's record from form A...

  • Thread starter Thread starter KHV
  • Start date Start date
K

KHV

Both forms 'A' and 'B' have field 'ProductID'.... Clicking a button on form
'A', I want form 'B' to open with all records from it's connected table, but
being navigated to the record that has the same 'ProductID' value as the
'ProductID' in form 'A'...

I know how to open the form using: DoCmd.OpenForm "Products".... but I can't
figure out how to navigate to the correct record ?

Thank's
Kjartan
 
KHV said:
Both forms 'A' and 'B' have field 'ProductID'.... Clicking a button
on form 'A', I want form 'B' to open with all records from it's
connected table, but being navigated to the record that has the same
'ProductID' value as the 'ProductID' in form 'A'...

I know how to open the form using: DoCmd.OpenForm "Products".... but
I can't figure out how to navigate to the correct record ?

Thank's
Kjartan

This will work in an Access 2000+ database:

'----- start of example code -----
DoCmd.OpenForm "Products"

If Not IsNull(Me.ProductID) Then
Forms!Products.Recordset.FindFirst "ProductID=" & Me.ProductID
End If
'----- end of example code -----
 
Check Access VB Help on the OpenForm Method and pay attention to the
"WhereCondition" argument of this method.
 
Perfect!... Thank's :)

Dirk Goldgar said:
This will work in an Access 2000+ database:

'----- start of example code -----
DoCmd.OpenForm "Products"

If Not IsNull(Me.ProductID) Then
Forms!Products.Recordset.FindFirst "ProductID=" & Me.ProductID
End If
'----- end of example code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
I wanted the form to open all records and being navigated to one record...
As far as I know, the 'WhereCondition' will only allow record(s) matching
the 'WhereCondition' to be opened... Right ?
 
Back
Top