Setting Rowsource Property

S

Simon Harris

Hi All,

I am trying to set the rowsource property of a list box using code.

Heres what I have, which is fired onload of the form:

'Set the Record Source for the customers list
Forms!frm_switchboard!SUBFRM_view_customers.RowSource = "SELECT
QRY_customers_view.ID, QRY_customers_view.surname,
QRY_customers_view.first_name AS Name, QRY_customers_view.company AS
Company, QRY_customers_view.tel AS Tel, QRY_customers_view.mobile AS Mobile,
QRY_customers_view.postcode AS Postcode, QRY_customers_view.type AS Type
FROM QRY_customers_view;"
MsgBox (Forms!frm_switchboard!SUBFRM_view_customers.RowSource)
Forms!frm_switchboard!SUBFRM_view_customers.Requery

Although there are no errors, I end up with nothing in the list box. Note
that the actual SQL I am trying to set as the rowsource is the original SQL
that was entered as the rowsource manually for the properties of the
listbox, so no probs there.

The MsgBox pops up what I expect - The SQL

Thanks

Simon.

--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
 
G

Gary Miller

Simon,

Your problem most likely lies in this line, but without
knowing your subform control name, I cannot give you the
exact solution. The key here is that you need to refer to
the name of the subform control that holds the subform and
then refer to it's form property and then to the listbox
control name. You can't directly refer to the subform
itself....

Forms!frm_switchboard!SUBFRM_view_customers.RowSource =
"SELECT...

should be something like...

Forms!frm_switchboard!YourSubFormControlName.Form!YourListBo
xName.RowSource = "SELECT...

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
Simon Harris said:
Hi All,

I am trying to set the rowsource property of a list box using code.

Heres what I have, which is fired onload of the form:

'Set the Record Source for the customers list
Forms!frm_switchboard!SUBFRM_view_customers.RowSource = "SELECT
QRY_customers_view.ID, QRY_customers_view.surname,
QRY_customers_view.first_name AS Name, QRY_customers_view.company AS
Company, QRY_customers_view.tel AS Tel,
QRY_customers_view.mobile AS Mobile,
QRY_customers_view.postcode AS Postcode,
QRY_customers_view.type AS Type
 

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

Similar Threads


Top