ComboBox - VBA

T

TF

I'm fairly new to VBA programming and am in need of help!

I have a form that has a ComboBox object. Can someone help by posting
code that would assign a customized field, (let's say, Text1) as it's
Control Source, RowSourceType as a value list, and values (let's say,
"yes", "no") as it's RowSource?

I'd really appreciate any feedback.
 
M

Mike Glen

Hi TF,

Try posting on the developer newsgroup. Please see FAQ Item: 24. Project
Newsgroups. FAQs, companion products and other useful Project information
can be seen at this web address: http://project.mvps.org/faqs.htm

Mike Glen
Project MVP
 
J

John

TF said:
I'm fairly new to VBA programming and am in need of help!

I have a form that has a ComboBox object. Can someone help by posting
code that would assign a customized field, (let's say, Text1) as it's
Control Source, RowSourceType as a value list, and values (let's say,
"yes", "no") as it's RowSource?

I'd really appreciate any feedback.

TF,
First of all the RowSourceType Property applies only to Excel. Second,
are you sure you want a ComboBox and not a ListBox? Nonetheless, the
following code will set up a userform ComboBox with the list values from
custom Task Text1:

Private Sub UserForm_initialize()
On Error Resume Next
For i = 1 To 10
UserForm1.ComBx1.AddItem
CustomFieldValueListGetItem(pjCustomTaskText1, pjlistvalue, i)
If Err > 0 Then Exit For
Next i
On Error GoTo 0
End Sub

Note: the error function is needed since the CustomFieldListGetItem
doesn't have a Count Property. I arbitrarily set the upper limit on the
index ("i") at 10. Increase or decrease it if you have a reasonable idea
of how many values are in the list.

Hope this helps.
John
Project MVP
 

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