Selection Does Not Appear In Combobox

S

Steve

I have a continuous form with several unbound comboboxes in the form header. The
comboboxes are used to provide criteria for the SQL of the form. The code behind
the form looks like:

Public Sub FormSQL()
Dim SQLStr As String
SQLStr = < Code to build SQL String based on selection in comboboxes>
SQLStr = SQLStr & ";"
Me.RecordSource = SQLStr
End Sub

Each combobox contains this code:

Private Sub <NameOfCombobox>_AfterUpdate()
Call FormSQL()
End Sub

Everything works fine as long as the the SQL returns one or more records.
However, when a selection is made in any combobox and that selection causes the
SQL to not return any records, the combobox goes blank rather than displaying
the selection. If another selection is then made in the same combobox that also
does not return any records in the SQL, that selection does appear in the
combobox.

Does anyone have any ideas as to why the first selection does not appear in the
combobox?

Thanks!

Steve
 
W

Wayne Morgan

I don't know why it happens, but a possible work around would be to check the number of
records returned by the sql before you tell the form to use it.
 

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