getting nil popupmenu box

My first box is being populated but not the next one, please help

[code]dbfile=getfolderitem(“C:\Users\Richard\Desktop\elite fitness\elite fitness\ew Folder\training folder\ew Folder\clientinfo.sqlite”)
db.databasefile=dbfile

dim sqlstring3 as string

if db.connect()then

sqlstring3 = "SELECT DISTINCT name1  FROM clientstats WHERE Trainer="+""+PopupMenu1.text+""+"order name1 by asec"

rs= db.sqlSelect  (sqlstring3)


numberofrecords = rs.recordCount

for row =1 to numberofrecords
  s= rs.field("name1").stringValue
  rs.movenext
  popupmenu2.addrow (s)
  
next

else
msgBox"database closed"

end if[/code]

Edit (Paul): Added code tags for code block.

First box? Do you mean first row of the PoupupMenu?

Anyway, your code should look more like this:

[code]While Not rs.EOF
s = rs.Field(“name1”).StringValue
PopupMenu2.AddRow(s)

rs.MoveNext
Wend[/code]

If you only see one row in the PopupMenu, that would imply that only one row was selected from the database table.

Paul,
rs is still equaling nil.
The first PopupMenu is populating correctly. It is selecting Trainer(s) correctly, any ideas.

There is only one PopupMenu in your example code, so I’m not sure what you mean. If the rs is Nil after the SQLSelect, then you have a DB error, you should check DBError and DBErrorMessage.

This is the same as

WHERE Trainer=" + PopupMenu1.text + "order

What you need to do is

WHERE Trainer = """ + PopupMenu1.text + """ order

A second mistake is here:

… should be:

ORDER BY name ASC

Thank you the PopupMenu boxes are working now just need to populate the text boxes with that info. I appreciate the help.