Querys in recordset

A

Alma

Hello:
I need to do a seek within a form in the following way:

One combo with clients : When I select a Client, I need to get in the
recordset only all records of that Client.
Another combo with invoice number: When I select a Invoice, I need to get
in the same recordset only that invoice.

How Can I do that?

thank you
 
J

John Vinson

Hello:
I need to do a seek within a form in the following way:

One combo with clients : When I select a Client, I need to get in the
recordset only all records of that Client.
Another combo with invoice number: When I select a Invoice, I need to get
in the same recordset only that invoice.

How Can I do that?

thank you

Let's say you have unbound combo boxes (the MUST be unbound, i.e. have
no Control Source - otherwise you'll replace the ClientID of the
currently selected record when you try to seek another one!) named
cboClientID and cboInvoiceID. In those combo's AfterUpdate event put
code like this (using your own fieldnames of course):

Private Sub cboClientID_AfterUpdate()
If IsNull(Me!cboClientID) Then ' user cleared the search
Me.Filter = ""
Me.FilterOn = False
Else
Me.Filter = "[ClientID] = " & Me!cboClientID
Me.FilterOn = True
End If
End Sub


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
A

Alma

Thank you.
How do I say to the recordset that update the information of filter?

John Vinson said:
Hello:
I need to do a seek within a form in the following way:

One combo with clients : When I select a Client, I need to get in the
recordset only all records of that Client.
Another combo with invoice number: When I select a Invoice, I need to get
in the same recordset only that invoice.

How Can I do that?

thank you

Let's say you have unbound combo boxes (the MUST be unbound, i.e. have
no Control Source - otherwise you'll replace the ClientID of the
currently selected record when you try to seek another one!) named
cboClientID and cboInvoiceID. In those combo's AfterUpdate event put
code like this (using your own fieldnames of course):

Private Sub cboClientID_AfterUpdate()
If IsNull(Me!cboClientID) Then ' user cleared the search
Me.Filter = ""
Me.FilterOn = False
Else
Me.Filter = "[ClientID] = " & Me!cboClientID
Me.FilterOn = True
End If
End Sub


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
J

John Vinson

Thank you.
How do I say to the recordset that update the information of filter?

I'm sorry, I do not understand your question. My suggestion filters
the Form's Recordsource and displays those records which match the
filter.

If you wish to actually change the recordsource query itself, you must
build the SQL string in code. Is that what you mean?

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
A

Alma

Thank you.
How do I say to the recordset that update the information of filter?

I forgot that I have a subform within the principal form I want to filter in
that subform

Thank you again
 
Top