Populating a list box (Part2)

T

Tony Williams

I have a search form that has a command button that opens a form to show the
results of the form. This is the code behind the OnClick event
Private Sub cmdFind_Click()

Dim strSQL As String

If Not BuildSQLString(strSQL) Then
MsgBox "There was a problem building the SQL string"
Exit Sub
End If
MsgBox strSQL

CurrentDb.QueryDefs("qryExample").SQL = strSQL
DoCmd.OpenForm "copy of frmInstitution", acNormal

End Sub
The qryExample is built at run time with code in a function called
BuildSQLString
The "qryexample" is then joined to another query, "qryjoin" that joins my
two tables, tbldocument and tblInstitution1, and the resultant query,
"qryresults" forms the control source for the form "copy of frmInstitution".

However rather than open the form I would like to populate a list box on my
search form with the results of "qryresults" can someone help me with this
and what additional information do you need?

Thanks
Tony
 
A

AccessVandal via AccessMonster.com

Try this,

Me.YourListBoxName.RowSource = "YourQueryNameHere"
Me.YourListBoxName.Requery
 
T

Tony Williams

Got it! I put on the code in the onclick of the command button, worked fine!
Thanks
Tony
Tony Williams said:
Thanks would that go in the OnGotFocus property?
Thanks
Tony
 

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