combo box - SQL criteria

G

gaba

Hi,
I'm using SQL Server MSDE RelA (BackEnd) Access Project (FrontEnd).

What I'm trying to do is to show a "contact" list in a Form (Contact table
link to Company table by Company_ID). I need to display only the contacts for
that company and when selected from the box, update the contact_Phone, Fax
and e-mail fields.

I'm using a query as the source and trying to match the Company ID in the
query with the Company ID in the form.
I used to use =forms![formname]![field] but it doesn't work with SQL.
Should I try a subform?

Any help will be greatly appreciated
 
M

Michel Walsh

Hi,


With MS SQL Server, in a adp, you can try to use a stored procedure and
have a control, in the form, with the same name as the argument of the
stored procedure, without the initial @. You have to requery the control
(Me.ComboBoxName.RowSource=Me.ComboBoxName.RowSource) after the control
changed.



Hoping it may help,
Vanderghast, Access MVP
 
G

gaba

Thanks Michel for your answer. Sorry it took me so long to try it. Since I'm
really new with SQL, could you please help me a little bit further and give
me an example of the stored prodedure and how to call it from the drop box?
1st drop box is [CompanyName].Company based on query Q_Company_List
2nd drop box is [Contact].MainContactName based on query Q_Contact_List

How can I "filter" the second drop box based on the Company_ID? both queries
have the same field.

Thanks so much in advance
--
gaba :)


Michel Walsh said:
Hi,


With MS SQL Server, in a adp, you can try to use a stored procedure and
have a control, in the form, with the same name as the argument of the
stored procedure, without the initial @. You have to requery the control
(Me.ComboBoxName.RowSource=Me.ComboBoxName.RowSource) after the control
changed.



Hoping it may help,
Vanderghast, Access MVP


gaba said:
Hi,
I'm using SQL Server MSDE RelA (BackEnd) Access Project (FrontEnd).

What I'm trying to do is to show a "contact" list in a Form (Contact table
link to Company table by Company_ID). I need to display only the contacts
for
that company and when selected from the box, update the contact_Phone, Fax
and e-mail fields.

I'm using a query as the source and trying to match the Company ID in the
query with the Company ID in the form.
I used to use =forms![formname]![field] but it doesn't work with SQL.
Should I try a subform?

Any help will be greatly appreciated
 
Top