A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

query to filter by current record id?



 
 
Thread Tools Display Modes
  #1  
Old December 14th, 2009, 02:32 PM posted to microsoft.public.access.queries
Seddon Acaster
external usenet poster
 
Posts: 1
Default query to filter by current record id?

2 tables called customer and service

customer table has unique numerical customer id field, this is the primary
key. an example value for this field would be 3

service table has customer id field and serviceno field. the customer id
field is not unique but the serviceno field is

i want a customer form to have a combobox that looks up a query that will
only show the serviceno fields that relate to that particular customer

how would i do this?
  #2  
Old December 14th, 2009, 03:43 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default query to filter by current record id?

Seddon -

Set the recordsource for the combobox to be a query with the criteria to set
it to the current customer ID. It will be something like this:

SELECT serviceno from [service table] where [Customer ID] = forms![Customer
form name]![Customer ID]

--
Daryl S


"Seddon Acaster" wrote:

2 tables called customer and service

customer table has unique numerical customer id field, this is the primary
key. an example value for this field would be 3

service table has customer id field and serviceno field. the customer id
field is not unique but the serviceno field is

i want a customer form to have a combobox that looks up a query that will
only show the serviceno fields that relate to that particular customer

how would i do this?

  #3  
Old December 14th, 2009, 04:19 PM posted to microsoft.public.access.queries
Seddon Acaster[_2_]
external usenet poster
 
Posts: 6
Default query to filter by current record id?

This is what i've entered in the Row Source for the Combo Box:

SELECT scan_id FROM service WHERE [ac_ref]=forms![customer_full]![ac_ref];

The data the Combo Box shows is the same for all records at the moment which
obviously is not what I want. Have I missed something out?

And er thanks by the way!

Seddon

"Daryl S" wrote:

Seddon -

Set the recordsource for the combobox to be a query with the criteria to set
it to the current customer ID. It will be something like this:

SELECT serviceno from [service table] where [Customer ID] = forms![Customer
form name]![Customer ID]

--
Daryl S


"Seddon Acaster" wrote:

2 tables called customer and service

customer table has unique numerical customer id field, this is the primary
key. an example value for this field would be 3

service table has customer id field and serviceno field. the customer id
field is not unique but the serviceno field is

i want a customer form to have a combobox that looks up a query that will
only show the serviceno fields that relate to that particular customer

how would i do this?

  #4  
Old December 15th, 2009, 02:50 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default query to filter by current record id?

Seddon -

You need to have the combo box requery after a customer record is selected.
I don't know how your form is set up or how a user navigates to the correct
customer, but the event that loads the record should have a requery for the
combo box, something like this:

Me.cboname.Requery

You may want this in the OnCurrent event in the form. If this doesn't work,
tell us what is in the combo box - is it all records?
--
Daryl S


"Seddon Acaster" wrote:

This is what i've entered in the Row Source for the Combo Box:

SELECT scan_id FROM service WHERE [ac_ref]=forms![customer_full]![ac_ref];

The data the Combo Box shows is the same for all records at the moment which
obviously is not what I want. Have I missed something out?

And er thanks by the way!

Seddon

"Daryl S" wrote:

Seddon -

Set the recordsource for the combobox to be a query with the criteria to set
it to the current customer ID. It will be something like this:

SELECT serviceno from [service table] where [Customer ID] = forms![Customer
form name]![Customer ID]

--
Daryl S


"Seddon Acaster" wrote:

2 tables called customer and service

customer table has unique numerical customer id field, this is the primary
key. an example value for this field would be 3

service table has customer id field and serviceno field. the customer id
field is not unique but the serviceno field is

i want a customer form to have a combobox that looks up a query that will
only show the serviceno fields that relate to that particular customer

how would i do this?

  #5  
Old December 15th, 2009, 08:19 PM posted to microsoft.public.access.queries
Seddon Acaster[_2_]
external usenet poster
 
Posts: 6
Default query to filter by current record id?

Thanks Daryl, that did the job nicely.

Seddon

"Daryl S" wrote:

Seddon -

You need to have the combo box requery after a customer record is selected.
I don't know how your form is set up or how a user navigates to the correct
customer, but the event that loads the record should have a requery for the
combo box, something like this:

Me.cboname.Requery

You may want this in the OnCurrent event in the form. If this doesn't work,
tell us what is in the combo box - is it all records?
--
Daryl S


"Seddon Acaster" wrote:

This is what i've entered in the Row Source for the Combo Box:

SELECT scan_id FROM service WHERE [ac_ref]=forms![customer_full]![ac_ref];

The data the Combo Box shows is the same for all records at the moment which
obviously is not what I want. Have I missed something out?

And er thanks by the way!

Seddon

"Daryl S" wrote:

Seddon -

Set the recordsource for the combobox to be a query with the criteria to set
it to the current customer ID. It will be something like this:

SELECT serviceno from [service table] where [Customer ID] = forms![Customer
form name]![Customer ID]

--
Daryl S


"Seddon Acaster" wrote:

2 tables called customer and service

customer table has unique numerical customer id field, this is the primary
key. an example value for this field would be 3

service table has customer id field and serviceno field. the customer id
field is not unique but the serviceno field is

i want a customer form to have a combobox that looks up a query that will
only show the serviceno fields that relate to that particular customer

how would i do this?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:02 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.