Limiting contents of combo

  • Thread starter Thread starter Jonathan Blitz
  • Start date Start date
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."
 
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."
|
|
|
 
Back
Top