default value of combo box?

J

JethroUK©

How might i express the default value of a combobox (start_date) as being
the first item in the existing list?

default value =[start_date].[Itemdata(0)]
 
D

Douglas J. Steele

Regardless of what the data type is, the default value property is a string,
so it must have quotes around it.

Try putting code similar to below in the form's Load event:

Me.MyCombo.DefaultValue = Chr$(34) & Me.MyCombo.ItemDate(0) & Chr$(34)
 
J

JethroUK©

it doesn't seem to like that - thanks anyhow - the fact that default value
has an expression builder suggests it will accept an expression - i've even
tried the expression builder and whilst it shows combo box object, it
doesn't show 'Itemdata' in the list of properties (virtually everything but)


Douglas J. Steele said:
Regardless of what the data type is, the default value property is a string,
so it must have quotes around it.

Try putting code similar to below in the form's Load event:

Me.MyCombo.DefaultValue = Chr$(34) & Me.MyCombo.ItemDate(0) & Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JethroUK© said:
How might i express the default value of a combobox (start_date) as being
the first item in the existing list?

default value =[start_date].[Itemdata(0)]
 
D

Douglas J. Steele

Really? It worked fine for me when I tested before posting.

What problem are you having?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JethroUK© said:
it doesn't seem to like that - thanks anyhow - the fact that default value
has an expression builder suggests it will accept an expression - i've
even
tried the expression builder and whilst it shows combo box object, it
doesn't show 'Itemdata' in the list of properties (virtually everything
but)


Douglas J. Steele said:
Regardless of what the data type is, the default value property is a string,
so it must have quotes around it.

Try putting code similar to below in the form's Load event:

Me.MyCombo.DefaultValue = Chr$(34) & Me.MyCombo.ItemDate(0) & Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JethroUK© said:
How might i express the default value of a combobox (start_date) as being
the first item in the existing list?

default value =[start_date].[Itemdata(0)]
 
J

JethroUK©

my fault - i'd mis-typed it so got #Error - sorry :blush:~

but it works now:

Start_Date.DefaultValue = "=[Start Date].[itemdata](0)"

:blush:)

which is char 34? it seems to work without it


Douglas J. Steele said:
Really? It worked fine for me when I tested before posting.

What problem are you having?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JethroUK© said:
it doesn't seem to like that - thanks anyhow - the fact that default value
has an expression builder suggests it will accept an expression - i've
even
tried the expression builder and whilst it shows combo box object, it
doesn't show 'Itemdata' in the list of properties (virtually everything
but)


Douglas J. Steele said:
Regardless of what the data type is, the default value property is a string,
so it must have quotes around it.

Try putting code similar to below in the form's Load event:

Me.MyCombo.DefaultValue = Chr$(34) & Me.MyCombo.ItemDate(0) & Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



How might i express the default value of a combobox (start_date) as being
the first item in the existing list?

default value =[start_date].[Itemdata(0)]
 
D

Douglas J. Steele

Chr$(34) is a double quote.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JethroUK© said:
my fault - i'd mis-typed it so got #Error - sorry :blush:~

but it works now:

Start_Date.DefaultValue = "=[Start Date].[itemdata](0)"

:blush:)

which is char 34? it seems to work without it


Douglas J. Steele said:
Really? It worked fine for me when I tested before posting.

What problem are you having?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JethroUK© said:
it doesn't seem to like that - thanks anyhow - the fact that default value
has an expression builder suggests it will accept an expression - i've
even
tried the expression builder and whilst it shows combo box object, it
doesn't show 'Itemdata' in the list of properties (virtually everything
but)


message
Regardless of what the data type is, the default value property is a
string,
so it must have quotes around it.

Try putting code similar to below in the form's Load event:

Me.MyCombo.DefaultValue = Chr$(34) & Me.MyCombo.ItemDate(0) & Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



How might i express the default value of a combobox (start_date) as
being
the first item in the existing list?

default value =[start_date].[Itemdata(0)]
 
J

JethroUK©

ah! thanx

Douglas J. Steele said:
Chr$(34) is a double quote.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



JethroUK© said:
my fault - i'd mis-typed it so got #Error - sorry :blush:~

but it works now:

Start_Date.DefaultValue = "=[Start Date].[itemdata](0)"

:blush:)

which is char 34? it seems to work without it


Douglas J. Steele said:
Really? It worked fine for me when I tested before posting.

What problem are you having?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



it doesn't seem to like that - thanks anyhow - the fact that default value
has an expression builder suggests it will accept an expression - i've
even
tried the expression builder and whilst it shows combo box object, it
doesn't show 'Itemdata' in the list of properties (virtually everything
but)


message
Regardless of what the data type is, the default value property is a
string,
so it must have quotes around it.

Try putting code similar to below in the form's Load event:

Me.MyCombo.DefaultValue = Chr$(34) & Me.MyCombo.ItemDate(0) & Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



How might i express the default value of a combobox (start_date) as
being
the first item in the existing list?

default value =[start_date].[Itemdata(0)]
 

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