RowSource property of unbound combobox used for record nav does not reflect as expected

  • Thread starter Thread starter Ivan Starr
  • Start date Start date
I

Ivan Starr

Hello, thanks for helping.

I have an unbound combobox in a subform whose rows I would like to filter by
criteria in another control during the OnCurrent() event. the code is as
follows:

If txtJN <> Null Then
cboSubmittalNumber.RowSource = "select [Submittals].[LoringsSubmittalNumber]
from [Submittals] where ([Submittals].[JN] = '" _
+ txtJN.Value + "');"
End If

where txtJN is the control I wish to filter the cboSubmittalNumber control's
rows on. It selects all records as if there was no WHERE clause. Funny
thing is, I thought it was working, but then it stopped filtering for some
reason. And now I've been going nuts for 3 hours trying to figure out why.

Does anyone have any idea?

Thanks,

Ivan
 
Just a thought, but if you're changing the row source 'on the fly', then
have you used the requery method after setting the row source? The row
source doesn't change until you either requery it or or close the form and
open it again.

HTH

Adam
 
Ivan,

There seems to be an unmatched right parenthesis in your rowsource select
statement, which would normally produce an error message at runtime (but is
not picked up by the VB editor, as it is onclosed in quotes), unless you
have some error handling in your code which results in either the particular
line or a bigger chunk of code being skipped (On Error Resume Next, On
Error Goto ...).
Try changing the expression to:

cboSubmittalNumber.RowSource = "select [Submittals].[LoringsSubmittalNumber]
from [Submittals] where ([Submittals].[JN] = '" _
+ txtJN.Value + "';"

and see if that fixes it.
If not, comment out the error handling and Debug > Step Into (F8) so you
identify the guilty line and get the error message for it.

HTH,
Nikos
 
Back
Top