Default combobox line

  • Thread starter Thread starter Rod Speed
  • Start date Start date
R

Rod Speed

OK, I've got a form that works fine with the user selecting a combobox entry
that is required manually.

I want to set the default when the form is opened so you only need to do that if
the default isnt what you want.

I dont want it to be the first item in the list, tho that would be a viable
kludge.

How do I do that ?
 
If you don't want it to be the first item in the list, what _do_ you want it
to be?

Larry Linson
Microsoft Access MVP
 
Larry Linson said:
If you don't want it to be the first item in the list, what _do_ you want it
to be?

One of the other items that I specify.

Looks like the default value of that control is
what I need from another post elsewhere.
 
I think you are on the right track. If it will always be the same item in
the list, regardless of position, then use the Default Value property of the
combo box.
 
Klatuu said:
I think you are on the right track. If it will always be the same
item in the list, regardless of position, then use the Default Value
property of the combo box.

I dont really mind if the default value moves around in the list as other
items are added, I just want to have one particular item as the default.

My initial superficial reaction to the use of the default property was
that that item has to be entered twice, once as an item in the table
that contains the items, once in the default property. That isnt hard
to fix with another field in the table that flags which item is the default
and the OnOpen or OnLoad Event can just get that item and put it
into the default property of the control.
 
As to entering it twice, there is not much you can do about that. I do like
the idea of having a field in the table that identifies the defalut choice.
I would not suggest using an event to set it. Instead, I think you might use
a DLookUp in the default value to do that for your:
=DLookUp("[TheField]","MyTableName","[DEFAULT_ITEM] = True")
Where [TheField] is the bound field for the combo box you want to be the
default value and [DEFAULT_ITEM] is the field you mentioned that will tell
you which is the default selection. You will need to change the names to
protect the innocent.

This is an untested idea, but if it works, it would be a cool way to do it.
(I think it will)
 
Klatuu said:
As to entering it twice, there is not much you can do about that.
I do like the idea of having a field in the table that identifies the
defalut choice. I would not suggest using an event to set it.
Instead, I think you might use a DLookUp in the default value to do
that for your: =DLookUp("[TheField]","MyTableName","[DEFAULT_ITEM] =
True")
Where [TheField] is the bound field for the combo box you want to be
the default value and [DEFAULT_ITEM] is the field you mentioned that
will tell you which is the default selection. You will need to
change the names to protect the innocent.

Yeah, that's what I meant, with that control.DefaultValue=dlookup(etc)
in the OnOpen event for the form.
This is an untested idea, but if it works, it
would be a cool way to do it. (I think it will)

It doesnt currently for some reason, likely just a brain fart on my part tho.
Although the control.DefaultValue string is correct, for some reason it
doesnt end up in the control property.
 
Put it in the Default Value property of the combo box.

Rod Speed said:
Klatuu said:
As to entering it twice, there is not much you can do about that.
I do like the idea of having a field in the table that identifies the
defalut choice. I would not suggest using an event to set it.
Instead, I think you might use a DLookUp in the default value to do
that for your: =DLookUp("[TheField]","MyTableName","[DEFAULT_ITEM] =
True")
Where [TheField] is the bound field for the combo box you want to be
the default value and [DEFAULT_ITEM] is the field you mentioned that
will tell you which is the default selection. You will need to
change the names to protect the innocent.

Yeah, that's what I meant, with that control.DefaultValue=dlookup(etc)
in the OnOpen event for the form.
This is an untested idea, but if it works, it
would be a cool way to do it. (I think it will)

It doesnt currently for some reason, likely just a brain fart on my part tho.
Although the control.DefaultValue string is correct, for some reason it
doesnt end up in the control property.

Rod Speed wrote
 
Rod Speed said:
Klatuu said:
As to entering it twice, there is not much you can do about that.
I do like the idea of having a field in the table that identifies the
defalut choice. I would not suggest using an event to set it.
Instead, I think you might use a DLookUp in the default value to do
that for your: =DLookUp("[TheField]","MyTableName","[DEFAULT_ITEM] =
True")
Where [TheField] is the bound field for the combo box you want to be
the default value and [DEFAULT_ITEM] is the field you mentioned that
will tell you which is the default selection. You will need to
change the names to protect the innocent.

Yeah, that's what I meant, with that control.DefaultValue=dlookup(etc)
in the OnOpen event for the form.
This is an untested idea, but if it works, it
would be a cool way to do it. (I think it will)

It doesnt currently for some reason, likely just a brain fart on my
part tho. Although the control.DefaultValue string is correct, for
some reason it doesnt end up in the control property.

What does work is to set the Default Value to
=[Drive].[ItemData](1)
when you want the second item in the list to be the default value

Not at all clear why I cant set it from visual basic tho.

 
Klatuu said:
Put it in the Default Value property of the combo box.

Yeah, my brain fart there, that works fine.

And the only problem with doing it in the OnOpen event was
not including an = on the front of the string that is written to the
Default Value property. For some reason its happy without that
if you enter it manually in the control property but not from code.


Rod Speed said:
Klatuu said:
As to entering it twice, there is not much you can do about that.
I do like the idea of having a field in the table that identifies
the defalut choice. I would not suggest using an event to set it.
Instead, I think you might use a DLookUp in the default value to do
that for your: =DLookUp("[TheField]","MyTableName","[DEFAULT_ITEM] =
True")
Where [TheField] is the bound field for the combo box you want to be
the default value and [DEFAULT_ITEM] is the field you mentioned that
will tell you which is the default selection. You will need to
change the names to protect the innocent.

Yeah, that's what I meant, with that
control.DefaultValue=dlookup(etc)
in the OnOpen event for the form.
This is an untested idea, but if it works, it
would be a cool way to do it. (I think it will)

It doesnt currently for some reason, likely just a brain fart on my
part tho. Although the control.DefaultValue string is correct, for
some reason it doesnt end up in the control property.

Rod Speed wrote
Klatuu <[email protected]> wrote
I think you are on the right track. If it will always be the same
item in the list, regardless of position, then use the Default
Value property of the combo box.

I dont really mind if the default value moves around in the list as
other items are added, I just want to have one particular item as
the default.

My initial superficial reaction to the use of the default property
was that that item has to be entered twice, once as an item in the
table
that contains the items, once in the default property. That isnt
hard to fix with another field in the table that flags which item
is the default and the OnOpen or OnLoad Event can just get that
item and put it
into the default property of the control.


:


If you don't want it to be the first item in the list, what _do_
you want it to be?

One of the other items that I specify.

Looks like the default value of that control is
what I need from another post elsewhere.


OK, I've got a form that works fine with the user selecting a
combobox entry that is required manually.

I want to set the default when the form is opened so you only
need to do that if the default isnt what you want.

I dont want it to be the first item in the list, tho that would
be a viable kludge.

How do I do that ?
 
Are you saying it does not work with the Dlookup in the Default Value
property of the combo box?

Rod Speed said:
Rod Speed said:
Klatuu said:
As to entering it twice, there is not much you can do about that.
I do like the idea of having a field in the table that identifies the
defalut choice. I would not suggest using an event to set it.
Instead, I think you might use a DLookUp in the default value to do
that for your: =DLookUp("[TheField]","MyTableName","[DEFAULT_ITEM] =
True")
Where [TheField] is the bound field for the combo box you want to be
the default value and [DEFAULT_ITEM] is the field you mentioned that
will tell you which is the default selection. You will need to
change the names to protect the innocent.

Yeah, that's what I meant, with that control.DefaultValue=dlookup(etc)
in the OnOpen event for the form.
This is an untested idea, but if it works, it
would be a cool way to do it. (I think it will)

It doesnt currently for some reason, likely just a brain fart on my
part tho. Although the control.DefaultValue string is correct, for
some reason it doesnt end up in the control property.

What does work is to set the Default Value to
=[Drive].[ItemData](1)
when you want the second item in the list to be the default value

Not at all clear why I cant set it from visual basic tho.
 
Klatuu said:
Are you saying it does not work with the Dlookup
in the Default Value property of the combo box?

No, that works fine and is the best way to do it.
I didnt register that that was what you meant by
not doing it in an event.

The only problem with doing it from code was that you
need an = on the front of what is written to the default
value property for some reason, even tho you dont if
you put a fixed string in the default value property manually.

Rod Speed said:
Rod Speed said:
As to entering it twice, there is not much you can do about that.
I do like the idea of having a field in the table that identifies
the defalut choice. I would not suggest using an event to set it.
Instead, I think you might use a DLookUp in the default value to do
that for your: =DLookUp("[TheField]","MyTableName","[DEFAULT_ITEM]
= True")
Where [TheField] is the bound field for the combo box you want to
be the default value and [DEFAULT_ITEM] is the field you mentioned
that will tell you which is the default selection. You will need
to change the names to protect the innocent.

Yeah, that's what I meant, with that
control.DefaultValue=dlookup(etc) in the OnOpen event for the form.

This is an untested idea, but if it works, it
would be a cool way to do it. (I think it will)

It doesnt currently for some reason, likely just a brain fart on my
part tho. Although the control.DefaultValue string is correct, for
some reason it doesnt end up in the control property.

What does work is to set the Default Value to
=[Drive].[ItemData](1)
when you want the second item in the list to be the default value

Not at all clear why I cant set it from visual basic tho.

Rod Speed wrote

I think you are on the right track. If it will always be the
same item in the list, regardless of position, then use the
Default Value property of the combo box.

I dont really mind if the default value moves around in the list
as other items are added, I just want to have one particular item
as the default.

My initial superficial reaction to the use of the default property
was that that item has to be entered twice, once as an item in the
table
that contains the items, once in the default property. That isnt
hard to fix with another field in the table that flags which item
is the default and the OnOpen or OnLoad Event can just get that
item and put it
into the default property of the control.


:


If you don't want it to be the first item in the list, what
_do_ you want it to be?

One of the other items that I specify.

Looks like the default value of that control is
what I need from another post elsewhere.


OK, I've got a form that works fine with the user selecting a
combobox entry that is required manually.

I want to set the default when the form is opened so you only
need to do that if the default isnt what you want.

I dont want it to be the first item in the list, tho that
would be a viable kludge.

How do I do that ?
 
Back
Top