Combobox column 1

E

Edward

Hi everybody,
I use a form for data entry , one of the combo boxes I have uses the Table
ID, first +last name ( column count 2, column widths 0,4) because first
column has width 0 it doenst show in the form ( i dont need to see the id
just first namd and last name ) my question is how can i retrive the ID from
this drop down list. I want to write a query based on the selection on this
combo box ( when user selects a first, last name I want to populate a textbox
on teh form which shows anothr field from the same table using its primary
key.
I guess its easier to ask how can we retrive a combo column not the entire
text( value)?
 
J

John W. Vinson

Hi everybody,
I use a form for data entry , one of the combo boxes I have uses the Table
ID, first +last name ( column count 2, column widths 0,4) because first
column has width 0 it doenst show in the form ( i dont need to see the id
just first namd and last name ) my question is how can i retrive the ID from
this drop down list. I want to write a query based on the selection on this
combo box ( when user selects a first, last name I want to populate a textbox
on teh form which shows anothr field from the same table using its primary
key.

Simply make column 1 (the ID) the Bound Column. Note that if you're using the
combo for selection rather than for updating, it should be an UNBOUND combo
(nothing in its Control Source). To refer to it in a query just use

=[Forms]![NameOfForm]![NameOfCombo]

as a criterion - do include the brackets.
I guess its easier to ask how can we retrive a combo column not the entire
text( value)?

=[Forms]![NameOfForm]![NameOfCombo].Column(n)

where n is the zero based index of the desired column (i.e. (0) for the first
column, (3) for the fourth) will let you see any column. For the task you
asked about, though, just make the the bound column property 1 (confusingly
that property is NOT zero based).
 
E

Edward

Thanks John.
I get an error what does [forms]! stand for shouldn't [name of
form]![]nameof combobox] be enough?
--
Best regards,
Edward


John W. Vinson said:
Hi everybody,
I use a form for data entry , one of the combo boxes I have uses the Table
ID, first +last name ( column count 2, column widths 0,4) because first
column has width 0 it doenst show in the form ( i dont need to see the id
just first namd and last name ) my question is how can i retrive the ID from
this drop down list. I want to write a query based on the selection on this
combo box ( when user selects a first, last name I want to populate a textbox
on teh form which shows anothr field from the same table using its primary
key.

Simply make column 1 (the ID) the Bound Column. Note that if you're using the
combo for selection rather than for updating, it should be an UNBOUND combo
(nothing in its Control Source). To refer to it in a query just use

=[Forms]![NameOfForm]![NameOfCombo]

as a criterion - do include the brackets.
I guess its easier to ask how can we retrive a combo column not the entire
text( value)?

=[Forms]![NameOfForm]![NameOfCombo].Column(n)

where n is the zero based index of the desired column (i.e. (0) for the first
column, (3) for the fourth) will let you see any column. For the task you
asked about, though, just make the the bound column property 1 (confusingly
that property is NOT zero based).
 
D

Douglas J. Steele

What's the error you're getting?

No, [name of form]![nameof combobox] isn't enough.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Edward said:
Thanks John.
I get an error what does [forms]! stand for shouldn't [name of
form]![]nameof combobox] be enough?
--
Best regards,
Edward


John W. Vinson said:
Hi everybody,
I use a form for data entry , one of the combo boxes I have uses the
Table
ID, first +last name ( column count 2, column widths 0,4) because first
column has width 0 it doenst show in the form ( i dont need to see the
id
just first namd and last name ) my question is how can i retrive the ID
from
this drop down list. I want to write a query based on the selection on
this
combo box ( when user selects a first, last name I want to populate a
textbox
on teh form which shows anothr field from the same table using its
primary
key.

Simply make column 1 (the ID) the Bound Column. Note that if you're using
the
combo for selection rather than for updating, it should be an UNBOUND
combo
(nothing in its Control Source). To refer to it in a query just use

=[Forms]![NameOfForm]![NameOfCombo]

as a criterion - do include the brackets.
I guess its easier to ask how can we retrive a combo column not the
entire
text( value)?

=[Forms]![NameOfForm]![NameOfCombo].Column(n)

where n is the zero based index of the desired column (i.e. (0) for the
first
column, (3) for the fourth) will let you see any column. For the task you
asked about, though, just make the the bound column property 1
(confusingly
that property is NOT zero based).
 
E

Edward

I opened the form and also I used a query to test if it will create correct
results.
Query is based on a table that I use to populate the drop down list and I
wrote the following expression in its ID( primary key) field
[Forms]![Session-staff-Schedule]![Session_ID].Column(1) after i run the
query I get the following error
Un defined function [Forms]![Session-staff-Schedule]![Session_ID].Column' in
expression.

By the way recently these newsgroup sites are sometimes unavailable or don't
load properly , Is this problem from my side or you guys have the same
expirence?
Thanks again
--
Best regards,
Edward


John W. Vinson said:
Thanks John.
I get an error

What error?
what does [forms]! stand for

A reference to the Forms collection consisting of all currently open forms.
shouldn't [name of
form]![]nameof combobox] be enough?

Nope.
 
J

John W. Vinson

I opened the form and also I used a query to test if it will create correct
results.
Query is based on a table that I use to populate the drop down list and I
wrote the following expression in its ID( primary key) field
[Forms]![Session-staff-Schedule]![Session_ID].Column(1) after i run the
query I get the following error
Un defined function [Forms]![Session-staff-Schedule]![Session_ID].Column' in
expression.

You can use the Column() property of a combo box in VBA code... but I believe
you cannot do so in a Query. You can reference the bound column of a combo by
using the name of the combo (just omit the Column(1) part).
By the way recently these newsgroup sites are sometimes unavailable or don't
load properly , Is this problem from my side or you guys have the same
expirence?

Since I don't use the webpage - which *IS* buggy and unreliable! - I've had no
trouble, but I know that many folks have. The newsgroups are *not* the same as
the Office webpage; the latter is actually just a newsreader, and not a very
good one at that. You can use a real newsreader (such as XNews, Agent, or even
Outlook Express or Windows Mail) directed to the news server
msnews.microsoft.com to see the questions and answers; you don't get the fancy
web interface or the icons categorizing responses though.
 

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