From: Sandi Vogel on
From one of yesterday's threads, I managed to figure out how to populate
combo boxes when the form initializes. I had two yesterday that were working
correctly. They are cboAIFRelationship and cbo2ndAIFRelationship
(designating a primary and a secondary Attorney in Fact, and their
relationship to client (i.e., spouse or brother). Today, I added a third
combo box for the county of residence (cboCounty), and I have strange results:

The cboAIFRelationship populates with both lists, and the
cbo2ndAIFRelationship has nothing. cboCounty populates correctly. I've
combed through this over and over, but see nothing wrong. I don't think it's
the properties of the combo box, because I copied each from the first one; so
the width and everything should be the same, right? Any help is appreciated!
Here is my code:

Private Sub UserForm_Initialize()

Me.cboAIFRelationship.Style = fmStyleDropDownCombo
Me.cboAIFRelationship.BoundColumn = 0
With Me
.cboAIFRelationship.AddItem "spouse"
.cboAIFRelationship.AddItem "son"
.cboAIFRelationship.AddItem "daughter"
.cboAIFRelationship.AddItem "son-in-law"
.cboAIFRelationship.AddItem "daughter-in-law"
.cboAIFRelationship.AddItem "brother"
.cboAIFRelationship.AddItem "sister"
.cboAIFRelationship.AddItem "father"
.cboAIFRelationship.AddItem "mother"
End With

Me.cbo2ndAIFRelationship.Style = fmStyleDropDownCombo
Me.cbo2ndAIFRelationship.BoundColumn = 0
With Me
.cboAIFRelationship.AddItem "spouse"
.cboAIFRelationship.AddItem "son"
.cboAIFRelationship.AddItem "daughter"
.cboAIFRelationship.AddItem "son-in-law"
.cboAIFRelationship.AddItem "daughter-in-law"
.cboAIFRelationship.AddItem "brother"
.cboAIFRelationship.AddItem "sister"
.cboAIFRelationship.AddItem "father"
.cboAIFRelationship.AddItem "mother"
End With

Me.cboCounty.Style = fmStyleDropDownCombo
Me.cboCounty.BoundColumn = 0
With Me
.cboCounty.AddItem "Allegany County"
.cboCounty.AddItem "Anne Arundel County"
.cboCounty.AddItem "Baltimore City"
.cboCounty.AddItem "Baltimore County"
.cboCounty.AddItem "Calvert County"
.cboCounty.AddItem "Caroline County"
.cboCounty.AddItem "Carroll County"
.cboCounty.AddItem "Cecil County"
.cboCounty.AddItem "Charles County"
.cboCounty.AddItem "Dorchester County"
.cboCounty.AddItem "Frederick County"
.cboCounty.AddItem "Garrett County"
.cboCounty.AddItem "Harford County"
.cboCounty.AddItem "Howard County"
.cboCounty.AddItem "Kent County"
.cboCounty.AddItem "Montgomery County"
.cboCounty.AddItem "Prince George's County"
.cboCounty.AddItem "Queen Anne's County"
.cboCounty.AddItem "St. Mary's County"
End With

End Sub

From: Sandi Vogel on
Doh! Typos! Sorry! Ignore this. (Unless you want to point out something
I'm doing wrong besides the obvious problem!)

"Sandi Vogel" wrote:

> From one of yesterday's threads, I managed to figure out how to populate
> combo boxes when the form initializes. I had two yesterday that were working
> correctly. They are cboAIFRelationship and cbo2ndAIFRelationship
> (designating a primary and a secondary Attorney in Fact, and their
> relationship to client (i.e., spouse or brother). Today, I added a third
> combo box for the county of residence (cboCounty), and I have strange results:
>
> The cboAIFRelationship populates with both lists, and the
> cbo2ndAIFRelationship has nothing. cboCounty populates correctly. I've
> combed through this over and over, but see nothing wrong. I don't think it's
> the properties of the combo box, because I copied each from the first one; so
> the width and everything should be the same, right? Any help is appreciated!
> Here is my code:
>
> Private Sub UserForm_Initialize()
>
> Me.cboAIFRelationship.Style = fmStyleDropDownCombo
> Me.cboAIFRelationship.BoundColumn = 0
> With Me
> .cboAIFRelationship.AddItem "spouse"
> .cboAIFRelationship.AddItem "son"
> .cboAIFRelationship.AddItem "daughter"
> .cboAIFRelationship.AddItem "son-in-law"
> .cboAIFRelationship.AddItem "daughter-in-law"
> .cboAIFRelationship.AddItem "brother"
> .cboAIFRelationship.AddItem "sister"
> .cboAIFRelationship.AddItem "father"
> .cboAIFRelationship.AddItem "mother"
> End With
>
> Me.cbo2ndAIFRelationship.Style = fmStyleDropDownCombo
> Me.cbo2ndAIFRelationship.BoundColumn = 0
> With Me
> .cboAIFRelationship.AddItem "spouse"
> .cboAIFRelationship.AddItem "son"
> .cboAIFRelationship.AddItem "daughter"
> .cboAIFRelationship.AddItem "son-in-law"
> .cboAIFRelationship.AddItem "daughter-in-law"
> .cboAIFRelationship.AddItem "brother"
> .cboAIFRelationship.AddItem "sister"
> .cboAIFRelationship.AddItem "father"
> .cboAIFRelationship.AddItem "mother"
> End With
>
> Me.cboCounty.Style = fmStyleDropDownCombo
> Me.cboCounty.BoundColumn = 0
> With Me
> .cboCounty.AddItem "Allegany County"
> .cboCounty.AddItem "Anne Arundel County"
> .cboCounty.AddItem "Baltimore City"
> .cboCounty.AddItem "Baltimore County"
> .cboCounty.AddItem "Calvert County"
> .cboCounty.AddItem "Caroline County"
> .cboCounty.AddItem "Carroll County"
> .cboCounty.AddItem "Cecil County"
> .cboCounty.AddItem "Charles County"
> .cboCounty.AddItem "Dorchester County"
> .cboCounty.AddItem "Frederick County"
> .cboCounty.AddItem "Garrett County"
> .cboCounty.AddItem "Harford County"
> .cboCounty.AddItem "Howard County"
> .cboCounty.AddItem "Kent County"
> .cboCounty.AddItem "Montgomery County"
> .cboCounty.AddItem "Prince George's County"
> .cboCounty.AddItem "Queen Anne's County"
> .cboCounty.AddItem "St. Mary's County"
> End With
>
> End Sub
>
From: Doug Robbins - Word MVP on
You could have just used

With cboAIFRelationship
.AddItem "spouse"
.AddItem "son"
.AddItem "daughter"
.AddItem "son-in-law"
.AddItem "daughter-in-law"
.AddItem "brother"
.AddItem "sister"
.AddItem "father"
.AddItem "mother"
End With

Combo boxes have the attributes that you are setting by the first two lines
of code as defaults so there is no need to specifically set them.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Sandi Vogel" <SandiVogel(a)discussions.microsoft.com> wrote in message
news:C0C41316-B7DA-474D-85C5-BF3CD1BFB9C9(a)microsoft.com...
> From one of yesterday's threads, I managed to figure out how to populate
> combo boxes when the form initializes. I had two yesterday that were
> working
> correctly. They are cboAIFRelationship and cbo2ndAIFRelationship
> (designating a primary and a secondary Attorney in Fact, and their
> relationship to client (i.e., spouse or brother). Today, I added a third
> combo box for the county of residence (cboCounty), and I have strange
> results:
>
> The cboAIFRelationship populates with both lists, and the
> cbo2ndAIFRelationship has nothing. cboCounty populates correctly. I've
> combed through this over and over, but see nothing wrong. I don't think
> it's
> the properties of the combo box, because I copied each from the first one;
> so
> the width and everything should be the same, right? Any help is
> appreciated!
> Here is my code:
>
> Private Sub UserForm_Initialize()
>
> Me.cboAIFRelationship.Style = fmStyleDropDownCombo
> Me.cboAIFRelationship.BoundColumn = 0
> With Me
> .cboAIFRelationship.AddItem "spouse"
> .cboAIFRelationship.AddItem "son"
> .cboAIFRelationship.AddItem "daughter"
> .cboAIFRelationship.AddItem "son-in-law"
> .cboAIFRelationship.AddItem "daughter-in-law"
> .cboAIFRelationship.AddItem "brother"
> .cboAIFRelationship.AddItem "sister"
> .cboAIFRelationship.AddItem "father"
> .cboAIFRelationship.AddItem "mother"
> End With
>
> Me.cbo2ndAIFRelationship.Style = fmStyleDropDownCombo
> Me.cbo2ndAIFRelationship.BoundColumn = 0
> With Me
> .cboAIFRelationship.AddItem "spouse"
> .cboAIFRelationship.AddItem "son"
> .cboAIFRelationship.AddItem "daughter"
> .cboAIFRelationship.AddItem "son-in-law"
> .cboAIFRelationship.AddItem "daughter-in-law"
> .cboAIFRelationship.AddItem "brother"
> .cboAIFRelationship.AddItem "sister"
> .cboAIFRelationship.AddItem "father"
> .cboAIFRelationship.AddItem "mother"
> End With
>
> Me.cboCounty.Style = fmStyleDropDownCombo
> Me.cboCounty.BoundColumn = 0
> With Me
> .cboCounty.AddItem "Allegany County"
> .cboCounty.AddItem "Anne Arundel County"
> .cboCounty.AddItem "Baltimore City"
> .cboCounty.AddItem "Baltimore County"
> .cboCounty.AddItem "Calvert County"
> .cboCounty.AddItem "Caroline County"
> .cboCounty.AddItem "Carroll County"
> .cboCounty.AddItem "Cecil County"
> .cboCounty.AddItem "Charles County"
> .cboCounty.AddItem "Dorchester County"
> .cboCounty.AddItem "Frederick County"
> .cboCounty.AddItem "Garrett County"
> .cboCounty.AddItem "Harford County"
> .cboCounty.AddItem "Howard County"
> .cboCounty.AddItem "Kent County"
> .cboCounty.AddItem "Montgomery County"
> .cboCounty.AddItem "Prince George's County"
> .cboCounty.AddItem "Queen Anne's County"
> .cboCounty.AddItem "St. Mary's County"
> End With
>
> End Sub
>


From: Sandi Vogel on
Thanks, Doug. I'm finally starting to get excited by (instead of intimidated
by) VBA, and all advice is welcome! I tried your method this morning, but
my resulting document read like so:

"my 1, Joe Smith..."
instead of "my spouse, Joe Smith..."

I suspect it has something to do with the bound column, which currently reads:
> > Me.cboAIFRelationship.BoundColumn = 0
I tried to change the # at the end of the line to 1, but that didn't
work...any ideas? Sorry, I'm no longer at the office, so I can't post the
code as it currently stands.
(Once I changed the with statements back to the way they were originally, my
resulting text was correct).

"Doug Robbins - Word MVP" wrote:

> You could have just used
>
> With cboAIFRelationship
> .AddItem "spouse"
> .AddItem "son"
> .AddItem "daughter"
> .AddItem "son-in-law"
> .AddItem "daughter-in-law"
> .AddItem "brother"
> .AddItem "sister"
> .AddItem "father"
> .AddItem "mother"
> End With
>
> Combo boxes have the attributes that you are setting by the first two lines
> of code as defaults so there is no need to specifically set them.
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Sandi Vogel" <SandiVogel(a)discussions.microsoft.com> wrote in message
> news:C0C41316-B7DA-474D-85C5-BF3CD1BFB9C9(a)microsoft.com...
> > From one of yesterday's threads, I managed to figure out how to populate
> > combo boxes when the form initializes. I had two yesterday that were
> > working
> > correctly. They are cboAIFRelationship and cbo2ndAIFRelationship
> > (designating a primary and a secondary Attorney in Fact, and their
> > relationship to client (i.e., spouse or brother). Today, I added a third
> > combo box for the county of residence (cboCounty), and I have strange
> > results:
> >
> > The cboAIFRelationship populates with both lists, and the
> > cbo2ndAIFRelationship has nothing. cboCounty populates correctly. I've
> > combed through this over and over, but see nothing wrong. I don't think
> > it's
> > the properties of the combo box, because I copied each from the first one;
> > so
> > the width and everything should be the same, right? Any help is
> > appreciated!
> > Here is my code:
> >
> > Private Sub UserForm_Initialize()
> >
> > Me.cboAIFRelationship.Style = fmStyleDropDownCombo
> > Me.cboAIFRelationship.BoundColumn = 0
> > With Me
> > .cboAIFRelationship.AddItem "spouse"
> > .cboAIFRelationship.AddItem "son"
> > .cboAIFRelationship.AddItem "daughter"
> > .cboAIFRelationship.AddItem "son-in-law"
> > .cboAIFRelationship.AddItem "daughter-in-law"
> > .cboAIFRelationship.AddItem "brother"
> > .cboAIFRelationship.AddItem "sister"
> > .cboAIFRelationship.AddItem "father"
> > .cboAIFRelationship.AddItem "mother"
> > End With
> >
> > Me.cbo2ndAIFRelationship.Style = fmStyleDropDownCombo
> > Me.cbo2ndAIFRelationship.BoundColumn = 0
> > With Me
> > .cboAIFRelationship.AddItem "spouse"
> > .cboAIFRelationship.AddItem "son"
> > .cboAIFRelationship.AddItem "daughter"
> > .cboAIFRelationship.AddItem "son-in-law"
> > .cboAIFRelationship.AddItem "daughter-in-law"
> > .cboAIFRelationship.AddItem "brother"
> > .cboAIFRelationship.AddItem "sister"
> > .cboAIFRelationship.AddItem "father"
> > .cboAIFRelationship.AddItem "mother"
> > End With
> >
> > Me.cboCounty.Style = fmStyleDropDownCombo
> > Me.cboCounty.BoundColumn = 0
> > With Me
> > .cboCounty.AddItem "Allegany County"
> > .cboCounty.AddItem "Anne Arundel County"
> > .cboCounty.AddItem "Baltimore City"
> > .cboCounty.AddItem "Baltimore County"
> > .cboCounty.AddItem "Calvert County"
> > .cboCounty.AddItem "Caroline County"
> > .cboCounty.AddItem "Carroll County"
> > .cboCounty.AddItem "Cecil County"
> > .cboCounty.AddItem "Charles County"
> > .cboCounty.AddItem "Dorchester County"
> > .cboCounty.AddItem "Frederick County"
> > .cboCounty.AddItem "Garrett County"
> > .cboCounty.AddItem "Harford County"
> > .cboCounty.AddItem "Howard County"
> > .cboCounty.AddItem "Kent County"
> > .cboCounty.AddItem "Montgomery County"
> > .cboCounty.AddItem "Prince George's County"
> > .cboCounty.AddItem "Queen Anne's County"
> > .cboCounty.AddItem "St. Mary's County"
> > End With
> >
> > End Sub
> >
>
>
>
From: Doug Robbins - Word MVP on
You would have to show us the code that is inserting the information into
the document.

Using the following to populate a combobox on a userform

With ComboBox1
.AddItem "spouse"
.AddItem "son"
.AddItem "daughter"
.AddItem "son-in-law"
.AddItem "daughter-in-law"
.AddItem "brother"
.AddItem "sister"
.AddItem "father"
.AddItem "mother"
End With

and then after selecting an item from the combobox and clicking on a command
button on the form that contains the following code:

Private Sub CommandButton1_Click()
MsgBox ComboBox1.Value
End Sub

The item that was selected in the combobox is displayed in the message box.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Sandi Vogel" <SandiVogel(a)discussions.microsoft.com> wrote in message
news:8F78AE89-D8A3-4ADC-92F0-AD4ADBAD0A75(a)microsoft.com...
> Thanks, Doug. I'm finally starting to get excited by (instead of
> intimidated
> by) VBA, and all advice is welcome! I tried your method this morning,
> but
> my resulting document read like so:
>
> "my 1, Joe Smith..."
> instead of "my spouse, Joe Smith..."
>
> I suspect it has something to do with the bound column, which currently
> reads:
>> > Me.cboAIFRelationship.BoundColumn = 0
> I tried to change the # at the end of the line to 1, but that didn't
> work...any ideas? Sorry, I'm no longer at the office, so I can't post the
> code as it currently stands.
> (Once I changed the with statements back to the way they were originally,
> my
> resulting text was correct).
>
> "Doug Robbins - Word MVP" wrote:
>
>> You could have just used
>>
>> With cboAIFRelationship
>> .AddItem "spouse"
>> .AddItem "son"
>> .AddItem "daughter"
>> .AddItem "son-in-law"
>> .AddItem "daughter-in-law"
>> .AddItem "brother"
>> .AddItem "sister"
>> .AddItem "father"
>> .AddItem "mother"
>> End With
>>
>> Combo boxes have the attributes that you are setting by the first two
>> lines
>> of code as defaults so there is no need to specifically set them.
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Sandi Vogel" <SandiVogel(a)discussions.microsoft.com> wrote in message
>> news:C0C41316-B7DA-474D-85C5-BF3CD1BFB9C9(a)microsoft.com...
>> > From one of yesterday's threads, I managed to figure out how to
>> > populate
>> > combo boxes when the form initializes. I had two yesterday that were
>> > working
>> > correctly. They are cboAIFRelationship and cbo2ndAIFRelationship
>> > (designating a primary and a secondary Attorney in Fact, and their
>> > relationship to client (i.e., spouse or brother). Today, I added a
>> > third
>> > combo box for the county of residence (cboCounty), and I have strange
>> > results:
>> >
>> > The cboAIFRelationship populates with both lists, and the
>> > cbo2ndAIFRelationship has nothing. cboCounty populates correctly.
>> > I've
>> > combed through this over and over, but see nothing wrong. I don't
>> > think
>> > it's
>> > the properties of the combo box, because I copied each from the first
>> > one;
>> > so
>> > the width and everything should be the same, right? Any help is
>> > appreciated!
>> > Here is my code:
>> >
>> > Private Sub UserForm_Initialize()
>> >
>> > Me.cboAIFRelationship.Style = fmStyleDropDownCombo
>> > Me.cboAIFRelationship.BoundColumn = 0
>> > With Me
>> > .cboAIFRelationship.AddItem "spouse"
>> > .cboAIFRelationship.AddItem "son"
>> > .cboAIFRelationship.AddItem "daughter"
>> > .cboAIFRelationship.AddItem "son-in-law"
>> > .cboAIFRelationship.AddItem "daughter-in-law"
>> > .cboAIFRelationship.AddItem "brother"
>> > .cboAIFRelationship.AddItem "sister"
>> > .cboAIFRelationship.AddItem "father"
>> > .cboAIFRelationship.AddItem "mother"
>> > End With
>> >
>> > Me.cbo2ndAIFRelationship.Style = fmStyleDropDownCombo
>> > Me.cbo2ndAIFRelationship.BoundColumn = 0
>> > With Me
>> > .cboAIFRelationship.AddItem "spouse"
>> > .cboAIFRelationship.AddItem "son"
>> > .cboAIFRelationship.AddItem "daughter"
>> > .cboAIFRelationship.AddItem "son-in-law"
>> > .cboAIFRelationship.AddItem "daughter-in-law"
>> > .cboAIFRelationship.AddItem "brother"
>> > .cboAIFRelationship.AddItem "sister"
>> > .cboAIFRelationship.AddItem "father"
>> > .cboAIFRelationship.AddItem "mother"
>> > End With
>> >
>> > Me.cboCounty.Style = fmStyleDropDownCombo
>> > Me.cboCounty.BoundColumn = 0
>> > With Me
>> > .cboCounty.AddItem "Allegany County"
>> > .cboCounty.AddItem "Anne Arundel County"
>> > .cboCounty.AddItem "Baltimore City"
>> > .cboCounty.AddItem "Baltimore County"
>> > .cboCounty.AddItem "Calvert County"
>> > .cboCounty.AddItem "Caroline County"
>> > .cboCounty.AddItem "Carroll County"
>> > .cboCounty.AddItem "Cecil County"
>> > .cboCounty.AddItem "Charles County"
>> > .cboCounty.AddItem "Dorchester County"
>> > .cboCounty.AddItem "Frederick County"
>> > .cboCounty.AddItem "Garrett County"
>> > .cboCounty.AddItem "Harford County"
>> > .cboCounty.AddItem "Howard County"
>> > .cboCounty.AddItem "Kent County"
>> > .cboCounty.AddItem "Montgomery County"
>> > .cboCounty.AddItem "Prince George's County"
>> > .cboCounty.AddItem "Queen Anne's County"
>> > .cboCounty.AddItem "St. Mary's County"
>> > End With
>> >
>> > End Sub
>> >
>>
>>
>>


 | 
Pages: 1
Prev: Printer Duplex
Next: Can't exit design mode