Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Populate dropdown box with information from other fields

0 views
Skip to first unread message

BZeyger

unread,
Nov 12, 2007, 11:39:04 AM11/12/07
to
I currently have a Access VBA database projetc. I have a form which uses
information from a current record. There are fields that populate perfectly.
I would like to add a dropdown box that will display the information from the
various fields.

Example:

The form conatins 3 non-visible fields : Writer1, Writer2, Writer3

I would like the drop-down to display Writer1, Writer2, and Writer3 of the
current record.

Is there a way to have it displayed directly from the object's property
window (Row Source) ?

John Spencer

unread,
Nov 12, 2007, 11:51:48 AM11/12/07
to
You could use the Current Event to set the comboboxes value list.

Set the Row Source Type of your combobox:
Row Source Type: Value List

Private Sub Form_Current()
Dim strList as string
strList = Me.Writer1 & ";" & Me.Writer2 & ":" & Me.Writer3
Me.YourCombobox.RowSource = strList
End Sub
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

"BZeyger" <BZe...@discussions.microsoft.com> wrote in message
news:15DACAE6-C691-40E8...@microsoft.com...

Douglas J. Steele

unread,
Nov 12, 2007, 12:44:25 PM11/12/07
to
Slight typo. It should be semi-colons in both places:

strList = Me.Writer1 & ";" & Me.Writer2 & ";" & Me.Writer3


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"John Spencer" <spe...@chpdm.edu> wrote in message
news:O7bLFxU...@TK2MSFTNGP04.phx.gbl...

BZeyger

unread,
Nov 12, 2007, 12:48:02 PM11/12/07
to
This code works however it does not show the desired results. Writer1,
Writer2, and Writer3 fields contain comma's in them. For example: Smith, John

The code provided does put the desired information into the drop-down box
but it does not place the full name on the same line.
What happens is: Smith
John
Doe
Jane

I would like it to show as : John, Smith
Jane Doe

"John Spencer" wrote:

> You could use the Current Event to set the comboboxes value list.
>
> Set the Row Source Type of your combobox:
> Row Source Type: Value List
>
> Private Sub Form_Current()
> Dim strList as string
> strList = Me.Writer1 & ";" & Me.Writer2 & ":" & Me.Writer3
> Me.YourCombobox.RowSource = strList
> End Sub
> --
> John Spencer
> Access MVP 2002-2005, 2007
> Center for Health Program Development and Management
> University of Maryland Baltimore County

> ..

BZeyger

unread,
Nov 12, 2007, 1:05:01 PM11/12/07
to
I have changed the typo to semicolons and the issue is still happening. It is
putting the first and last name on two seperate line.

Douglas J. Steele

unread,
Nov 12, 2007, 1:30:31 PM11/12/07
to
Try

strList = """" & Me.Writer1 & """;""" & Me.Writer2 & """;""" & Me.Writer3 &
""""

That's four double quotes in a row at the beginning and end, and three
double quotes on either side of the semi-colons.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"BZeyger" <BZe...@discussions.microsoft.com> wrote in message

news:D484156B-225D-4525...@microsoft.com...

John Spencer

unread,
Nov 12, 2007, 3:12:42 PM11/12/07
to
Perhaps I don't understand what you are attempting to do.

If you are trying to get the three parts of ONE Name as choices in a
combobox then you probably need to use a query as the source for the
combobox where you have concatenated (added together) three fields
containing the name parts. You can combine the three fields in the
underlying query.

Field: FirstName & " " & MiddleName & " " & LastName

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

"BZeyger" <BZe...@discussions.microsoft.com> wrote in message
news:5DF1EC96-BC0F-4E0C...@microsoft.com...

0 new messages