Combo box with 2 fields (1 Viewer)

Swedude

Registered User.
Local time
Today, 11:32
Joined
Jan 12, 2010
Messages
13
Access 2007. Got a form with a few combo boxes containing options. Each option concerns a First and Last Name. In the list, they show up as this:

John | Doe

But when I pick an option, only the John shows up. The same goes for my, or what is supposed to be my zip code + city combo box.

Is there a way to show the 2 fields in the same box, separated by a space? Or if I need a second field showing the second one, how does that work?
 

rainman89

I cant find the any key..
Local time
Today, 05:32
Joined
Feb 12, 2007
Messages
3,015
in the query for the combobox put

name: [firstname] & " " & [Lastname]
 

Swedude

Registered User.
Local time
Today, 11:32
Joined
Jan 12, 2010
Messages
13
Hmm, query? I'm making a form for registering a new client. It's based on the client table.
 

rainman89

I cant find the any key..
Local time
Today, 05:32
Joined
Feb 12, 2007
Messages
3,015
ok. but is the combobox based off of a query? You will find it in the rowsource property of the combobox. In there is where you would have to edit the query to put the information in
 

Swedude

Registered User.
Local time
Today, 11:32
Joined
Jan 12, 2010
Messages
13
Nope, only got tables and forms so far. Is that bad?
 

rainman89

I cant find the any key..
Local time
Today, 05:32
Joined
Feb 12, 2007
Messages
3,015
You shouldn't base forms directly off of tables, I would create queries to pull the same information..

As for the comboboxes, you can click the ellipses .... that is in the row sourse to create a query that will give you the information you are looking for and in there add the name: firstname&" "& lastname option
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:32
Joined
Sep 12, 2006
Messages
15,727
the combo box DISPLAYS the value of the first non-zero length field in the base query

so you can design the query to take adavantage of that, and combine fields to give you the display you want to see.

alternatively, you can have an extra text box on your form, and get the value of the "missing data" directly from the combo box - control source of =mycombobox.column(whatever)
 

Swedude

Registered User.
Local time
Today, 11:32
Joined
Jan 12, 2010
Messages
13
alternatively, you can have an extra text box on your form, and get the value of the "missing data" directly from the combo box - control source of =mycombobox.column(whatever)

Tried that but can't get it to work. I put 2 in the parentheses. What goes into the "mycombobox"? The name of the box or something else? Name doesn't seem to work.
 

Swedude

Registered User.
Local time
Today, 11:32
Joined
Jan 12, 2010
Messages
13
You shouldn't base forms directly off of tables, I would create queries to pull the same information..

As for the comboboxes, you can click the ellipses .... that is in the row sourse to create a query that will give you the information you are looking for and in there add the name: firstname&" "& lastname option

Why shouldn't they?

And where do I put in the name?
 

rainman89

I cant find the any key..
Local time
Today, 05:32
Joined
Feb 12, 2007
Messages
3,015
Why shouldn't they?

And where do I put in the name?

You don't want to give users direct access to tables! It's not a good habit to get into. It'll cause trouble down the road.

You would put that in a new field within the query
 

Swedude

Registered User.
Local time
Today, 11:32
Joined
Jan 12, 2010
Messages
13
It's a school asignment, it won't be used by anyone. Maybe you guessed that already, though. :p But in theory it's meant for workers who will be able to register new clients. There's no specifications regarding restrictions to database access.

As for the query, if I want the zipcode/seller fields etc, I have to select them from those classes since e.g. a "SellerID" field (foreign key in Client table) is no good. I need Seller First and Last name, but could I rename those in the query? Those field names only make sense inside the Seller class. Having "First Name" and "Last Name" field pop up in a query about the Client (a company) would be confusing.
 

rainman89

I cant find the any key..
Local time
Today, 05:32
Joined
Feb 12, 2007
Messages
3,015
It's a school asignment, it won't be used by anyone. Maybe you guessed that already, though. :p But in theory it's meant for workers who will be able to register new clients. There's no specifications regarding restrictions to database access.

As for the query, if I want the zipcode/seller fields etc, I have to select them from those classes since e.g. a "SellerID" field (foreign key in Client table) is no good. I need Seller First and Last name, but could I rename those in the query? Those field names only make sense inside the Seller class. Having "First Name" and "Last Name" field pop up in a query about the Client (a company) would be confusing.

I understand its a school assignment, but don't you wanna do it right?

I've given you the steps that you will need to take to do what you want to do. Look into building queries (Which requires some effort!!) and basing the combo boxes off of those queries. You will be able to do what you are asking.
 

Swedude

Registered User.
Local time
Today, 11:32
Joined
Jan 12, 2010
Messages
13
Could be. I'm a total noob at Access and there's not much time left.

Maybe I could use those queries for the "Search for Client" button as well as the Register Client form? That would be an upside.
 

rainman89

I cant find the any key..
Local time
Today, 05:32
Joined
Feb 12, 2007
Messages
3,015
That's definitely how you would do it
 

Users who are viewing this thread

Top Bottom