Limiting contents of combo

J

Jonathan Blitz

I have a combo box that displays rows from an SQL server table.
I want to limit the rows displayed based on one of the fields in the table.

So ...

In the FormOpen event I entered the following code:

Me.PlanAccessIdCombo.RowSourceType = "Table/Query"
Me.PlanAccessIdCombo.RowSource = "SELECT PlanAccessId, FromAccess,
ToAccess FROM tblPlanAccesses Where PlanId = " + CStr(Parent.PlanId)
Me.PlanAccessIdCombo.Requery

It doesn't work.
I have check the query using the debugger and it is set correctly. However
my conbo box is empty.
Why?

--
Jonathan Blitz
AnyKey Limited
Israel

"When things seem bad
Don't worry and shout
Just count up the times
Things have worked themselves out."
 
A

Alick [MSFT]

Hi Jonathan,

If you use ADP instead of MDB, we may need to change the RowSourceType to
be:

Me.PlanAccessIdCombo.RowSourceType = "Table/View/StoredProc"

If the data type of the field PlanId is Text/String, we may need to add
Chr(39) character single quotation mark between the string. For example:

Where PlanId = " & Chr(39) & CStr(Parent.PlanId) & Chr(39)

Please feel free to reply to the post if you have any concerns or questions.


Sincerely,

Alick Ye, MCSD
Product Support Services
Microsoft Corporation
Get Secure! - <www.microsoft.com/security>

This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
| From: "Jonathan Blitz" <[email protected]>
| Subject: Limiting contents of combo
| X-Tomcat-NG: microsoft.public.access.formscoding
|
| I have a combo box that displays rows from an SQL server table.
| I want to limit the rows displayed based on one of the fields in the
table.
|
| So ...
|
| In the FormOpen event I entered the following code:
|
| Me.PlanAccessIdCombo.RowSourceType = "Table/Query"
| Me.PlanAccessIdCombo.RowSource = "SELECT PlanAccessId, FromAccess,
| ToAccess FROM tblPlanAccesses Where PlanId = " + CStr(Parent.PlanId)
| Me.PlanAccessIdCombo.Requery
|
| It doesn't work.
| I have check the query using the debugger and it is set correctly. However
| my conbo box is empty.
| Why?
|
| --
| Jonathan Blitz
| AnyKey Limited
| Israel
|
| "When things seem bad
| Don't worry and shout
| Just count up the times
| Things have worked themselves out."
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top