help with combo box on my form

R

Rice

On all of my forms the the combo boxes are blank. The values are their when
you scroll down using the drop down box but they dont actual appear in plain
sight.
 
K

Klatuu

That would be true for unbound combos, and bound combos that have no default
value for new records.
For those bound combos, you can set a default value and it will show the
value as soon as you start entering data in the new record.
For unbound combos, you can use the form's load event to assign the combo a
value.
 
R

Rice

Thank you but I'm new with using Access and Im not exactly sure how to do
what your saying correctly. The combobox's are unbound should they be bound
and would I go to the properties of the form load event and add code to it?
The default value is not set. Help, please
 
K

Klatuu

any control may be bound or unbound.
Bound means it has the name of a field in the form's record source and will
show the data in the field it is bound to and it will allow the user to enter
a value that will then be updated in the table. The control's Control Source
property is used to bind the control to a field.

Unbound means the control is not associated with a data field. The Control
Source property can also be used for unbound controls to show a calculated
value. For example, say you have a field in your table named [DueDate] and
it is bound to a control on your form named txtDueDate and you want to show a
"Last Day of Grace" that is 5 days after the due date. You would not store
that in the table, but use a calculated control that would display it for the
user. You would use its Control Source like this:
=DateAdd("d", 5, txtDueDate)

So, whether you bind your controls depends on how you want to use them. A
Combo box is best used for two situations. One where you want to allow users
to enter only values from a specificied list and the value selected will be
stored in the table. The other is when you want to provide a user the
ability to search for a specific record in the form's recordset.

For entering value in a table, you would use a bound combo box. For
searching for specific records, you would use an unbound combo box.

Normally you would not load a value in a control unless there is a specific
reason to do so. The issue with a bound combo box is that the normal
behaviour when opening a form is for it to show the first record in the
form's recordset (the recordset is defined in the form's record source
property). So, if you set a specific value in a bound combo box, you will be
changing the value in the record. This is probably not what you want to do.

Entering a value in a combo used for searching for a record is unncessary,
but in some cases it is done for a reason. For example, I have some forms
where the filtering for the form is based on values in several different
combos, so they all need to have some value in them to get the correct
records in the form's recordset.

But for a direct answer to your question of how, if you are fairly new to
Access and not comfortable using VBA, I would suggest you start with a Macro.

Macros do actions. When you want to populate a control on a form, you use a
SetValue action. Then in the boxes at the bottom of the macro builder, you
enter the name of the form and the control on the form and the value you want
to put in it. The easy way to do this is while in design view of your form,
open the properties dialog and be sure the form is selected. Select the
Events tab. Click on the small button with 3 dots to the right of the text
box for On Load. Form the list that pops up, select Macro Builder. Build
the Macro and save it. Now when you load the form, the value will
automatically appear in the combo.
 
R

Rice

Thank you, this helps some. I am familar with VBA I normally code in Excel
that's why Access is new to me but if I understand correctly and please bare
with me...
if I want to use the combo to simply search for a value and store it the
table it should be bound. If I want the user to search for and enter a date
it should be unbound textbox and not a combo box.

What vba would you suggest I use for SetValue?
any control may be bound or unbound.
Bound means it has the name of a field in the form's record source and will
show the data in the field it is bound to and it will allow the user to enter
a value that will then be updated in the table. The control's Control Source
property is used to bind the control to a field.

Unbound means the control is not associated with a data field. The Control
Source property can also be used for unbound controls to show a calculated
value. For example, say you have a field in your table named [DueDate] and
it is bound to a control on your form named txtDueDate and you want to show a
"Last Day of Grace" that is 5 days after the due date. You would not store
that in the table, but use a calculated control that would display it for the
user. You would use its Control Source like this:
=DateAdd("d", 5, txtDueDate)

So, whether you bind your controls depends on how you want to use them. A
Combo box is best used for two situations. One where you want to allow users
to enter only values from a specificied list and the value selected will be
stored in the table. The other is when you want to provide a user the
ability to search for a specific record in the form's recordset.

For entering value in a table, you would use a bound combo box. For
searching for specific records, you would use an unbound combo box.

Normally you would not load a value in a control unless there is a specific
reason to do so. The issue with a bound combo box is that the normal
behaviour when opening a form is for it to show the first record in the
form's recordset (the recordset is defined in the form's record source
property). So, if you set a specific value in a bound combo box, you will be
changing the value in the record. This is probably not what you want to do.

Entering a value in a combo used for searching for a record is unncessary,
but in some cases it is done for a reason. For example, I have some forms
where the filtering for the form is based on values in several different
combos, so they all need to have some value in them to get the correct
records in the form's recordset.

But for a direct answer to your question of how, if you are fairly new to
Access and not comfortable using VBA, I would suggest you start with a Macro.

Macros do actions. When you want to populate a control on a form, you use a
SetValue action. Then in the boxes at the bottom of the macro builder, you
enter the name of the form and the control on the form and the value you want
to put in it. The easy way to do this is while in design view of your form,
open the properties dialog and be sure the form is selected. Select the
Events tab. Click on the small button with 3 dots to the right of the text
box for On Load. Form the list that pops up, select Macro Builder. Build
the Macro and save it. Now when you load the form, the value will
automatically appear in the combo.
Thank you but I'm new with using Access and Im not exactly sure how to do
what your saying correctly. The combobox's are unbound should they be bound
[quoted text clipped - 10 lines]
 
K

Klatuu

if I want to use the combo to simply search for a value and store it the
table it should be bound.
Yes

If I want the user to search for and enter a date
it should be unbound textbox and not a combo box.
What do you mean by search for and enter a date? Is is a date that exists
in the table? or what do you intende to do with the date?

As to using VBA, then instead of selecting Macro Builder, chose Code builder
and it will open the VB editor in the event. Then the syntax to populate a
control is:

Me.MyControName =

For example, if you want to put today's date in it would be:

Me.MyControlName = Date()

--
Dave Hargis, Microsoft Access MVP


Rice said:
Thank you, this helps some. I am familar with VBA I normally code in Excel
that's why Access is new to me but if I understand correctly and please bare
with me...
if I want to use the combo to simply search for a value and store it the
table it should be bound. If I want the user to search for and enter a date
it should be unbound textbox and not a combo box.

What vba would you suggest I use for SetValue?
any control may be bound or unbound.
Bound means it has the name of a field in the form's record source and will
show the data in the field it is bound to and it will allow the user to enter
a value that will then be updated in the table. The control's Control Source
property is used to bind the control to a field.

Unbound means the control is not associated with a data field. The Control
Source property can also be used for unbound controls to show a calculated
value. For example, say you have a field in your table named [DueDate] and
it is bound to a control on your form named txtDueDate and you want to show a
"Last Day of Grace" that is 5 days after the due date. You would not store
that in the table, but use a calculated control that would display it for the
user. You would use its Control Source like this:
=DateAdd("d", 5, txtDueDate)

So, whether you bind your controls depends on how you want to use them. A
Combo box is best used for two situations. One where you want to allow users
to enter only values from a specificied list and the value selected will be
stored in the table. The other is when you want to provide a user the
ability to search for a specific record in the form's recordset.

For entering value in a table, you would use a bound combo box. For
searching for specific records, you would use an unbound combo box.

Normally you would not load a value in a control unless there is a specific
reason to do so. The issue with a bound combo box is that the normal
behaviour when opening a form is for it to show the first record in the
form's recordset (the recordset is defined in the form's record source
property). So, if you set a specific value in a bound combo box, you will be
changing the value in the record. This is probably not what you want to do.

Entering a value in a combo used for searching for a record is unncessary,
but in some cases it is done for a reason. For example, I have some forms
where the filtering for the form is based on values in several different
combos, so they all need to have some value in them to get the correct
records in the form's recordset.

But for a direct answer to your question of how, if you are fairly new to
Access and not comfortable using VBA, I would suggest you start with a Macro.

Macros do actions. When you want to populate a control on a form, you use a
SetValue action. Then in the boxes at the bottom of the macro builder, you
enter the name of the form and the control on the form and the value you want
to put in it. The easy way to do this is while in design view of your form,
open the properties dialog and be sure the form is selected. Select the
Events tab. Click on the small button with 3 dots to the right of the text
box for On Load. Form the list that pops up, select Macro Builder. Build
the Macro and save it. Now when you load the form, the value will
automatically appear in the combo.
Thank you but I'm new with using Access and Im not exactly sure how to do
what your saying correctly. The combobox's are unbound should they be bound
[quoted text clipped - 10 lines]
you scroll down using the drop down box but they dont actual appear in plain
sight.
 
R

Rice via AccessMonster.com

I know your probably tired of me but what I mean I created a second combo box
the is bound to the table and retrieves the date but I the user must also be
able to add a date along with other data entry on the form and when they
select add new it creates a new record. So the second combo box has to
purposes one to hold the dates that exist on the table and two allow the user
the enter a date and other data entry as a new record.
thanks said:
if I want to use the combo to simply search for a value and store it the
table it should be bound.
Yes

If I want the user to search for and enter a date
it should be unbound textbox and not a combo box.
What do you mean by search for and enter a date? Is is a date that exists
in the table? or what do you intende to do with the date?

As to using VBA, then instead of selecting Macro Builder, chose Code builder
and it will open the VB editor in the event. Then the syntax to populate a
control is:

Me.MyControName =

For example, if you want to put today's date in it would be:

Me.MyControlName = Date()
Thank you, this helps some. I am familar with VBA I normally code in Excel
that's why Access is new to me but if I understand correctly and please bare
[quoted text clipped - 59 lines]
 
R

Rice via AccessMonster.com

One more thing before I call quits for the evening..made some changes as
suggested and my combo box values are invisible but if you click on the drop
down arrow the and click in the list area under the arrow thier are values
and it will pop up in the combo box but hte user can't see them to know what
they are selecting so I know it's a property that causing this.
I know your probably tired of me but what I mean I created a second combo box
the is bound to the table and retrieves the date but I the user must also be
able to add a date along with other data entry on the form and when they
select add new it creates a new record. So the second combo box has to
purposes one to hold the dates that exist on the table and two allow the user
the enter a date and other data entry as a new record.
thanks
if I want to use the combo to simply search for a value and store it the
table it should be bound. [quoted text clipped - 20 lines]
you scroll down using the drop down box but they dont actual appear in plain
sight.
 
K

Klatuu

Sorry, I don't quite understand your description.
--
Dave Hargis, Microsoft Access MVP


Rice via AccessMonster.com said:
One more thing before I call quits for the evening..made some changes as
suggested and my combo box values are invisible but if you click on the drop
down arrow the and click in the list area under the arrow thier are values
and it will pop up in the combo box but hte user can't see them to know what
they are selecting so I know it's a property that causing this.
I know your probably tired of me but what I mean I created a second combo box
the is bound to the table and retrieves the date but I the user must also be
able to add a date along with other data entry on the form and when they
select add new it creates a new record. So the second combo box has to
purposes one to hold the dates that exist on the table and two allow the user
the enter a date and other data entry as a new record.
thanks
if I want to use the combo to simply search for a value and store it the
table it should be bound.
[quoted text clipped - 20 lines]
you scroll down using the drop down box but they dont actual appear in plain
sight.
 
K

Klatuu

You really only need one combo box, unless there is something I am not
understanding.

In this case, your combo box would be a bound control so it udpdates and
displays the contents of a field in the form's recordset. If you want it to
have a specific value when you add a new record, then you assign it a Default
Value. The Default Value property will populate the control with the value
for new records, but it will not affect existing records.

Now if what you are saying is you want to repeat the current value of the
combo box for a new record, you can do that it the form's After Update event
by assigning the current value to the default value property:

Me.MyCombo.DefaultValue = Me.MyCombo

--
Dave Hargis, Microsoft Access MVP


Rice via AccessMonster.com said:
I know your probably tired of me but what I mean I created a second combo box
the is bound to the table and retrieves the date but I the user must also be
able to add a date along with other data entry on the form and when they
select add new it creates a new record. So the second combo box has to
purposes one to hold the dates that exist on the table and two allow the user
the enter a date and other data entry as a new record.
thanks said:
if I want to use the combo to simply search for a value and store it the
table it should be bound.
Yes

If I want the user to search for and enter a date
it should be unbound textbox and not a combo box.
What do you mean by search for and enter a date? Is is a date that exists
in the table? or what do you intende to do with the date?

As to using VBA, then instead of selecting Macro Builder, chose Code builder
and it will open the VB editor in the event. Then the syntax to populate a
control is:

Me.MyControName =

For example, if you want to put today's date in it would be:

Me.MyControlName = Date()
Thank you, this helps some. I am familar with VBA I normally code in Excel
that's why Access is new to me but if I understand correctly and please bare
[quoted text clipped - 59 lines]
you scroll down using the drop down box but they dont actual appear in plain
sight.
 
S

Scott Lindberg

If you have installed Office 2003 SP3 you need a hot fix to correct this issue. It also resolves many issue with check boxes.
 
S

Scott Lindberg

If you have installed Office 2003 SP3 you need a hot fix to correct this issue. It also resolves many issue with check boxes.
 

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