By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,067 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,067 IT Pros & Developers. It's quick & easy.

Cycling through a subform record from the master form

P: 2
I have a form called Invoice that has a subform called Invoice_datasheet. The subform has the field Customer as the child link and Customer_Name in the Invoice form (The master) as the master link which means I have 2 tables as well.
since my Invoice field is opened by a command button from another form, it is filtered out so that only one customer's invoices are shown at a time.
On the other hand, I have a searchbox in the form Invoice to look up any Invoice ID for any customer and it has the following vb code:

If Not IsNull(Forms![Invoice]![searchbox]) Then

Me.Filter = ""

Dim rs As Object
Dim strLinkValue As String

strLinkValue = Me![searchbox].Value
Set rs = Me.RecordsetClone
rs.FindFirst "[Invoice ID]=" & strLinkValue & ""
Forms!Invoice.Bookmark = rs.Bookmark
End If

The searchbox works perfectly but I want to create two buttons (Previous and Next) that cycle through the Invoices for the current customer. The two buttons work perfectly if the filter is on, but after I use the searchbox to look up an InvoiceID, the filter gets cleared out so those two buttons will cycle through all the invoices and not just through the invoices for the current customer.
How can I fix this? Is there any way to apply a filter so only current customer's invoices will be cycled?

Any help will be greatly appreciated and sorry for the long post
Jul 25 '09 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,287
As a user, I wouldn't expect choosing an invoice number to filter the recordset by customer. But if that's what you want to do, just add the lines
Expand|Select|Wrap|Line Numbers
  1. Me.Filter = "[Customer_Name] = '" & Customer_Name & "'"
  2. Me.FilterOn = True
This assumes Customer_Name is a text field. If it's numeric, the single quotes aren't needed.
Jul 27 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.