ListBox - Default Value = Max in box

  • Thread starter Thread starter Andibevan
  • Start date Start date
A

Andibevan

I have a listbox that is populated with the following query.

SELECT [tbl_Plog_CR_Import].[CR Number], [tbl_CR_Costs_Schedule].[CR Batch]
FROM tbl_Plog_CR_Import INNER JOIN tbl_CR_Costs_Schedule ON
[tbl_Plog_CR_Import].[CR Number]=[tbl_CR_Costs_Schedule].[CR Number];

How would I go about setting the default value to the max number in the
listbox.

I realise I could do this by putting some code in the Form's Load event but
was wondering if there was another method.

TIA

Andi
 
Andibevan said:
I have a listbox that is populated with the following query.

SELECT [tbl_Plog_CR_Import].[CR Number], [tbl_CR_Costs_Schedule].[CR
Batch] FROM tbl_Plog_CR_Import INNER JOIN tbl_CR_Costs_Schedule ON
[tbl_Plog_CR_Import].[CR Number]=[tbl_CR_Costs_Schedule].[CR Number];

How would I go about setting the default value to the max number in
the listbox.

I realise I could do this by putting some code in the Form's Load
event but was wondering if there was another method.

TIA

Andi

I think you're going to need code, and the Load event seems like the
right place to run it.
 
In case of adds or deletes, I would suggest the code go in the Current event.
As this might be a performance issue, I would suggest a module level boolean
varialbe set to True when any change (add, delete, modified) is made to the
recordset and only requery the list box and spin through the items looking
for the max value when the varialbe is true.

Dirk Goldgar said:
Andibevan said:
I have a listbox that is populated with the following query.

SELECT [tbl_Plog_CR_Import].[CR Number], [tbl_CR_Costs_Schedule].[CR
Batch] FROM tbl_Plog_CR_Import INNER JOIN tbl_CR_Costs_Schedule ON
[tbl_Plog_CR_Import].[CR Number]=[tbl_CR_Costs_Schedule].[CR Number];

How would I go about setting the default value to the max number in
the listbox.

I realise I could do this by putting some code in the Form's Load
event but was wondering if there was another method.

TIA

Andi

I think you're going to need code, and the Load event seems like the
right place to run it.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top