change rowsource for combobox

J

jokobe

Hi ng,

I want to change the rowsource for a combo box like this:

[forms]![my_form].[my_field].rowsource = new_source_string

This is working fine, and I have tried to put this code
in a public sub to use it for different forms and fields -
but I wasn't very successfull.

any helpful hints??

jokobe
 
R

Rick Brandt

jokobe said:
Hi ng,

I want to change the rowsource for a combo box like this:

[forms]![my_form].[my_field].rowsource = new_source_string

This is working fine, and I have tried to put this code
in a public sub to use it for different forms and fields -
but I wasn't very successfull.

any helpful hints??

Define "...wasn't very successful". Where were you running it when you say
it "worked fine"?
 
G

Guest

thanks for your answer.

I implemented the code in a form, lets say my_form, but
I need to have it in a global sub and tried it like this:

public sub change_source( a_form, a_source)

a_form.field.rowsource = a_source

end


call change_source (my_form, "select ...")

the select part is working, I can even pass the form name
into the public sub, but can't figure out how to pass
the field name, to have a sub for different forms and
different fields

joachim
-----Original Message-----
Hi ng,

I want to change the rowsource for a combo box like this:

[forms]![my_form].[my_field].rowsource = new_source_string

This is working fine, and I have tried to put this code
in a public sub to use it for different forms and fields -
but I wasn't very successfull.

any helpful hints??

Define "...wasn't very successful". Where were you running it when you say
it "worked fine"?


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


.
 
R

Rick Brandt

thanks for your answer.

I implemented the code in a form, lets say my_form, but
I need to have it in a global sub and tried it like this:

public sub change_source( a_form, a_source)

a_form.field.rowsource = a_source

end


call change_source (my_form, "select ...")

the select part is working, I can even pass the form name
into the public sub, but can't figure out how to pass
the field name, to have a sub for different forms and
different fields

I prefer to use Strings for this kind of stuff.

Public Sub Change_Source( a_form as String, a_control as String, a_source
as String)

Forms(a_form).Controls(a_control).RowSource = a_source

End

Change_Source("FormName", "ComboBoxName", "SQL String")
 

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