How to select record via combo box?

B

Brett

I have a combo box on a form and want to capture the value returned from a
user selection. The combo box is populated with values and displays two
columns. Nothing happens when I select something. The selection does not
appear in the top part of the combo so that it is always visible. How can I
do this?

Thanks,
Brett
 
S

sunberries

If the combo box is getting its data from a table, properties/data should
look something like this:
Row Source Type = Table/Query
Row Source = SELECT Tablename.fieldname, Yourtablename.[Other fieldnames
with space] FROM Tablename;

where Tablename = the table you are getting the data from
where fieldname = the specific field within the table

Other than this check out the rest of the field properties for something
that might have been turned off, e.g. visible = yes. The best practice would
to check out the sample database in access and copy the property settings of
the combo boxes in there. hope this helps.

Nelson
 
B

Brett

I couldn't find any *.mdb files that had forms. Should some of those that
come with access have forms?

Do you have a small DB that you could send which demonstrates how to capture
a record ID by selecting something in the drop down list box (combo box)? If
so, my email address is brettr_at_cygen_dot_com.

I'm doing as you mentioned and trying to capture the user selection but the
index returned is -1:
s = comboxbox.item
si = combobox.index(i)

The above code may not be syntactically correct. I don't have the DB with
me right now but it does work. Just that the combox box isn't really
returning anything. Also, which event should the above code go under?

Thanks,
Brett

sunberries said:
If the combo box is getting its data from a table, properties/data should
look something like this:
Row Source Type = Table/Query
Row Source = SELECT Tablename.fieldname, Yourtablename.[Other fieldnames
with space] FROM Tablename;

where Tablename = the table you are getting the data from
where fieldname = the specific field within the table

Other than this check out the rest of the field properties for something
that might have been turned off, e.g. visible = yes. The best practice
would
to check out the sample database in access and copy the property settings
of
the combo boxes in there. hope this helps.

Nelson

Brett said:
I have a combo box on a form and want to capture the value returned from
a
user selection. The combo box is populated with values and displays two
columns. Nothing happens when I select something. The selection does
not
appear in the top part of the combo so that it is always visible. How
can I
do this?

Thanks,
Brett
 
S

sunberries

Sir, There is a sample dtabase in Access (im using 2002 I dont know if there
is one in other versions) Simply click "Help" from the Menu, select "Sample
Databases", then select "Northwind Sample Database". The file is read only,
so if you find the object sample you are looking for, just copy it to your
database and dissect it from there. Or you can do what I did; locate the
sample database in your C: then copy and paste it to another location- this
removes it from read-only mode.

Brett said:
I couldn't find any *.mdb files that had forms. Should some of those that
come with access have forms?

Do you have a small DB that you could send which demonstrates how to capture
a record ID by selecting something in the drop down list box (combo box)? If
so, my email address is brettr_at_cygen_dot_com.

I'm doing as you mentioned and trying to capture the user selection but the
index returned is -1:
s = comboxbox.item
si = combobox.index(i)

The above code may not be syntactically correct. I don't have the DB with
me right now but it does work. Just that the combox box isn't really
returning anything. Also, which event should the above code go under?

Thanks,
Brett

sunberries said:
If the combo box is getting its data from a table, properties/data should
look something like this:
Row Source Type = Table/Query
Row Source = SELECT Tablename.fieldname, Yourtablename.[Other fieldnames
with space] FROM Tablename;

where Tablename = the table you are getting the data from
where fieldname = the specific field within the table

Other than this check out the rest of the field properties for something
that might have been turned off, e.g. visible = yes. The best practice
would
to check out the sample database in access and copy the property settings
of
the combo boxes in there. hope this helps.

Nelson

Brett said:
I have a combo box on a form and want to capture the value returned from
a
user selection. The combo box is populated with values and displays two
columns. Nothing happens when I select something. The selection does
not
appear in the top part of the combo so that it is always visible. How
can I
do this?

Thanks,
Brett
 
B

Brett

OK, I've found and installed Northwind. It does have a combo box. It lets
you select something and that item appears in the combo box. I don't see
what it is good for though. There aren't any events defined on this object.

I also set all properties on my combo box to exactly the same as the one in
Northwind. My combo still doesn't allow you to select anything. I know
there are three options you can define when creating the combo box. Is
there a way to view these properties after the combo has been created?

Thanks,
Brett

sunberries said:
Sir, There is a sample dtabase in Access (im using 2002 I dont know if
there
is one in other versions) Simply click "Help" from the Menu, select
"Sample
Databases", then select "Northwind Sample Database". The file is read
only,
so if you find the object sample you are looking for, just copy it to your
database and dissect it from there. Or you can do what I did; locate the
sample database in your C: then copy and paste it to another location-
this
removes it from read-only mode.

Brett said:
I couldn't find any *.mdb files that had forms. Should some of those
that
come with access have forms?

Do you have a small DB that you could send which demonstrates how to
capture
a record ID by selecting something in the drop down list box (combo box)?
If
so, my email address is brettr_at_cygen_dot_com.

I'm doing as you mentioned and trying to capture the user selection but
the
index returned is -1:
s = comboxbox.item
si = combobox.index(i)

The above code may not be syntactically correct. I don't have the DB
with
me right now but it does work. Just that the combox box isn't really
returning anything. Also, which event should the above code go under?

Thanks,
Brett

sunberries said:
If the combo box is getting its data from a table, properties/data
should
look something like this:
Row Source Type = Table/Query
Row Source = SELECT Tablename.fieldname, Yourtablename.[Other
fieldnames
with space] FROM Tablename;

where Tablename = the table you are getting the data from
where fieldname = the specific field within the table

Other than this check out the rest of the field properties for
something
that might have been turned off, e.g. visible = yes. The best practice
would
to check out the sample database in access and copy the property
settings
of
the combo boxes in there. hope this helps.

Nelson

:

I have a combo box on a form and want to capture the value returned
from
a
user selection. The combo box is populated with values and displays
two
columns. Nothing happens when I select something. The selection does
not
appear in the top part of the combo so that it is always visible. How
can I
do this?

Thanks,
Brett
 
S

sunberries

The combo box can be setup to get info from:
1. Pre-determined list (Value/List) = you create or type the choices on the
property window ex: Rowsource= Apples;Grapes;Oranges.
2.From a Table or Query = This row source type is used when you want to get
the info from, you guessed it, Query or Table.
3. Field list= it gets the field names...i dont really what this is for.

Now all these combo types wouldnt do anything but just show up the
selection, we have to assign an event to it to do something else than just
appear. The sample code below fetches all the other related data from the
selection you made. I placed this code on combo
properties/events/afterupdate:

Private Sub Comboname_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Fieldname] = '" & Me![Comboname] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Now, if what you want to get a set of records from one table to another
using a selection from a combo box, thats another topic and It would be best
to re-post with that question.

Brett said:
OK, I've found and installed Northwind. It does have a combo box. It lets
you select something and that item appears in the combo box. I don't see
what it is good for though. There aren't any events defined on this object.

I also set all properties on my combo box to exactly the same as the one in
Northwind. My combo still doesn't allow you to select anything. I know
there are three options you can define when creating the combo box. Is
there a way to view these properties after the combo has been created?

Thanks,
Brett

sunberries said:
Sir, There is a sample dtabase in Access (im using 2002 I dont know if
there
is one in other versions) Simply click "Help" from the Menu, select
"Sample
Databases", then select "Northwind Sample Database". The file is read
only,
so if you find the object sample you are looking for, just copy it to your
database and dissect it from there. Or you can do what I did; locate the
sample database in your C: then copy and paste it to another location-
this
removes it from read-only mode.

Brett said:
I couldn't find any *.mdb files that had forms. Should some of those
that
come with access have forms?

Do you have a small DB that you could send which demonstrates how to
capture
a record ID by selecting something in the drop down list box (combo box)?
If
so, my email address is brettr_at_cygen_dot_com.

I'm doing as you mentioned and trying to capture the user selection but
the
index returned is -1:
s = comboxbox.item
si = combobox.index(i)

The above code may not be syntactically correct. I don't have the DB
with
me right now but it does work. Just that the combox box isn't really
returning anything. Also, which event should the above code go under?

Thanks,
Brett

If the combo box is getting its data from a table, properties/data
should
look something like this:
Row Source Type = Table/Query
Row Source = SELECT Tablename.fieldname, Yourtablename.[Other
fieldnames
with space] FROM Tablename;

where Tablename = the table you are getting the data from
where fieldname = the specific field within the table

Other than this check out the rest of the field properties for
something
that might have been turned off, e.g. visible = yes. The best practice
would
to check out the sample database in access and copy the property
settings
of
the combo boxes in there. hope this helps.

Nelson

:

I have a combo box on a form and want to capture the value returned
from
a
user selection. The combo box is populated with values and displays
two
columns. Nothing happens when I select something. The selection does
not
appear in the top part of the combo so that it is always visible. How
can I
do this?

Thanks,
Brett
 
Top