J
Jan
Hi,
There are 2 problems I am having with filtering records...one is as follows.
I really wanted to do this on my own but I can't get the code correct (been
trying for about 2 weeks).
I have a form that is opened from an input box that displays a list of
customers that have a last name that begins with a string such as Hill*.
The list shows only only a few fields and shows them in continuous form
view. The user can scroll down and select a specific Customer and from
there I want to open another form in Form view that displays all of the
customer information for the customer record that the user selects with the
mouse. I have no problem displaying one record but the user must be able
to move forward and backward in the filtered recordset beginning with the
original record selected.
In other words, I want to open a form with a filtered recordset and make the
current record from the first form the displayed record in the second form.
Below is 2 examples of VBA code I've used. The program is Access 2000 (DAO)
#1 - opens the second form with the desired filter but displays the first
record in the filtered recordset as the current record not the selected
record.
Private Sub cmdOpenCustomers_Click()
dim rst as Recordset
dim stDocName as String
dim stLinkCriteria as String
set rst = Me.RecordsetClone
stDocName = "frmCustomers"
stLinkCriteria = Me.Filter
DoCmd.OpenForm stDocName, , , stLinkCriteria
rst.FindFirst ("[CustomerID =" & Me![CustomerID])
End Sub
#2 - opens the second form and makes the selected customer the only record.
Private Sub cmdOpenCustomers_Click()
dim rst as Recordset
dim stDocName as String
dim stLinkCriteria as String
set rst = Me.RecordsetClone
stDocName = "frmCustomers"
stLinkCriteria = ("[CustomerID =" & Me![CustomerID])
DoCmd.OpenForm stDocName, , Me.Filter, stLinkCriteria
End Sub
The second form (frmCustomers) is also used independently.
All help is greatly appreciated.
Jan
There are 2 problems I am having with filtering records...one is as follows.
I really wanted to do this on my own but I can't get the code correct (been
trying for about 2 weeks).
I have a form that is opened from an input box that displays a list of
customers that have a last name that begins with a string such as Hill*.
The list shows only only a few fields and shows them in continuous form
view. The user can scroll down and select a specific Customer and from
there I want to open another form in Form view that displays all of the
customer information for the customer record that the user selects with the
mouse. I have no problem displaying one record but the user must be able
to move forward and backward in the filtered recordset beginning with the
original record selected.
In other words, I want to open a form with a filtered recordset and make the
current record from the first form the displayed record in the second form.
Below is 2 examples of VBA code I've used. The program is Access 2000 (DAO)
#1 - opens the second form with the desired filter but displays the first
record in the filtered recordset as the current record not the selected
record.
Private Sub cmdOpenCustomers_Click()
dim rst as Recordset
dim stDocName as String
dim stLinkCriteria as String
set rst = Me.RecordsetClone
stDocName = "frmCustomers"
stLinkCriteria = Me.Filter
DoCmd.OpenForm stDocName, , , stLinkCriteria
rst.FindFirst ("[CustomerID =" & Me![CustomerID])
End Sub
#2 - opens the second form and makes the selected customer the only record.
Private Sub cmdOpenCustomers_Click()
dim rst as Recordset
dim stDocName as String
dim stLinkCriteria as String
set rst = Me.RecordsetClone
stDocName = "frmCustomers"
stLinkCriteria = ("[CustomerID =" & Me![CustomerID])
DoCmd.OpenForm stDocName, , Me.Filter, stLinkCriteria
End Sub
The second form (frmCustomers) is also used independently.
All help is greatly appreciated.
Jan