Combo box record source

B

Bassel

Hello

I have a form with a bound combo box to a field called code.
I try to use an if statment in the after update event of another control to
select only a part of the code field.

If Me.CodeType = 2 Then
Me.Code.RowSourceType = "Table/Query"
Me.Code.RowSource = "SELECT OrderedItems.PCode FROM OrderedItems WHERE
(((OrderedItems.CodeType)=2)); "
End If
However the combo box is blank.

Is there is a way to choose the Rowsource of a combobox depending on the
update of another control.

Best regards
 
D

david epsom dot com dot au

1) After changing the rowsource, you may need to
do something like

v = me.code.rowcount

In your example, you don't need to change the
rowsource. You just need a rowsource like:

"SELECT OrderedItems.PCode FROM OrderedItems WHERE
(((OrderedItems.CodeType)=[form].[codetype])); "


(david)
 
J

John Welch

why not just :
me.code.requery ?

david epsom dot com dot au said:
1) After changing the rowsource, you may need to
do something like

v = me.code.rowcount

In your example, you don't need to change the
rowsource. You just need a rowsource like:

"SELECT OrderedItems.PCode FROM OrderedItems WHERE
(((OrderedItems.CodeType)=[form].[codetype])); "


(david)


Bassel said:
Hello

I have a form with a bound combo box to a field called code.
I try to use an if statment in the after update event of another control
to
select only a part of the code field.

If Me.CodeType = 2 Then
Me.Code.RowSourceType = "Table/Query"
Me.Code.RowSource = "SELECT OrderedItems.PCode FROM OrderedItems WHERE
(((OrderedItems.CodeType)=2)); "
End If
However the combo box is blank.

Is there is a way to choose the Rowsource of a combobox depending on the
update of another control.

Best regards
 
Top