Combo box and ItemData

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 2 combo boxes for dates. The dates are from a table in which
duplicates are allowed. Therefore, I have a Select statement in the rowsource
that groups by date and sorts decending. This gets 1 of each date and sorts
the list in reverse order. New dates are added to the table every month so
the list length will increase. For the Ending Date combobox, I have the
Default Value set to:
=[EndDate].[ItemData](0)
This works well.

However, how would I get the last row of the list if I don't know how many
items are in the list for the Beginning Date? I tried something like:
=[EndDate].[ItemData]("Last Row")
without success. I typed Last Row without the quotes but Access added them.

I need to do this in the Default Value property of the combo box.

Thanks
 
The ListCount property should tell you how many entries there are. However,
I don't know if that property can be used the way you want. Certainly worth
a try.
=[EndDate].[ItemData](EndDate.ListCount)


Good Luck & HTH,
--
George Nicholson

Remove 'Junk' from return address.


RW said:
I have 2 combo boxes for dates. The dates are from a table in which
duplicates are allowed. Therefore, I have a Select statement in the
rowsource
that groups by date and sorts decending. This gets 1 of each date and
sorts
the list in reverse order. New dates are added to the table every month so
the list length will increase. For the Ending Date combobox, I have the
Default Value set to:
=[EndDate].[ItemData](0)
This works well.

However, how would I get the last row of the list if I don't know how many
items are in the list for the Beginning Date? I tried something like:
=[EndDate].[ItemData]("Last Row")
without success. I typed Last Row without the quotes but Access added
them.

I need to do this in the Default Value property of the combo box.

Thanks
 
Thanks for the reply. It didn't work. Access wanted to put brackets around
EndDate and ListCount so it looked like:
[EndDate].[ListCount]

George Nicholson said:
The ListCount property should tell you how many entries there are. However,
I don't know if that property can be used the way you want. Certainly worth
a try.
=[EndDate].[ItemData](EndDate.ListCount)


Good Luck & HTH,
--
George Nicholson

Remove 'Junk' from return address.


RW said:
I have 2 combo boxes for dates. The dates are from a table in which
duplicates are allowed. Therefore, I have a Select statement in the
rowsource
that groups by date and sorts decending. This gets 1 of each date and
sorts
the list in reverse order. New dates are added to the table every month so
the list length will increase. For the Ending Date combobox, I have the
Default Value set to:
=[EndDate].[ItemData](0)
This works well.

However, how would I get the last row of the list if I don't know how many
items are in the list for the Beginning Date? I tried something like:
=[EndDate].[ItemData]("Last Row")
without success. I typed Last Row without the quotes but Access added
them.

I need to do this in the Default Value property of the combo box.

Thanks
 
1) It should be: ListCount -1

2) It may simply be that you can't use it to set a Default property in Table
design, but you can achieve the same thing by coding the Form's Current
event (if a new record) to set the combo box's "default" value to
ListCount-1.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


RW said:
Thanks for the reply. It didn't work. Access wanted to put brackets around
EndDate and ListCount so it looked like:
[EndDate].[ListCount]

George Nicholson said:
The ListCount property should tell you how many entries there are.
However,
I don't know if that property can be used the way you want. Certainly
worth
a try.
=[EndDate].[ItemData](EndDate.ListCount)


Good Luck & HTH,
--
George Nicholson

Remove 'Junk' from return address.


RW said:
I have 2 combo boxes for dates. The dates are from a table in which
duplicates are allowed. Therefore, I have a Select statement in the
rowsource
that groups by date and sorts decending. This gets 1 of each date and
sorts
the list in reverse order. New dates are added to the table every month
so
the list length will increase. For the Ending Date combobox, I have the
Default Value set to:
=[EndDate].[ItemData](0)
This works well.

However, how would I get the last row of the list if I don't know how
many
items are in the list for the Beginning Date? I tried something like:
=[EndDate].[ItemData]("Last Row")
without success. I typed Last Row without the quotes but Access added
them.

I need to do this in the Default Value property of the combo box.

Thanks
 
I tried several iterations of the listCount -1 without success. Thanks for
trying.

George Nicholson said:
1) It should be: ListCount -1

2) It may simply be that you can't use it to set a Default property in Table
design, but you can achieve the same thing by coding the Form's Current
event (if a new record) to set the combo box's "default" value to
ListCount-1.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


RW said:
Thanks for the reply. It didn't work. Access wanted to put brackets around
EndDate and ListCount so it looked like:
[EndDate].[ListCount]

George Nicholson said:
The ListCount property should tell you how many entries there are.
However,
I don't know if that property can be used the way you want. Certainly
worth
a try.

=[EndDate].[ItemData](EndDate.ListCount)


Good Luck & HTH,
--
George Nicholson

Remove 'Junk' from return address.


I have 2 combo boxes for dates. The dates are from a table in which
duplicates are allowed. Therefore, I have a Select statement in the
rowsource
that groups by date and sorts decending. This gets 1 of each date and
sorts
the list in reverse order. New dates are added to the table every month
so
the list length will increase. For the Ending Date combobox, I have the
Default Value set to:
=[EndDate].[ItemData](0)
This works well.

However, how would I get the last row of the list if I don't know how
many
items are in the list for the Beginning Date? I tried something like:
=[EndDate].[ItemData]("Last Row")
without success. I typed Last Row without the quotes but Access added
them.

I need to do this in the Default Value property of the combo box.

Thanks
 
Back
Top