bug with list box in ac2000?

  • Thread starter Thread starter ChasW
  • Start date Start date
C

ChasW

I believe i stumbled across a bug in access 2000, but I am not sure.
I was hoping somebody here might have an explanation.

I should first mention that my ac2000 is patched to sp3 and the Jet
Engine is patched to the latest version.

Using a listbox in a form with Multi Select set to Extended, the
following code works fine during the Form Open event.

With Me.List27
.RowSourceType = "Value List"
.RowSource = ">=; >; =; <=; <"
.Selected(0) = True
End With

However, if I try to use the same list box with Multi Select set to
None, then at runtime none of the controls on the form are responsive
unless I remove the above line of code:

..Selected(0) = True

Why does a regular list box not want this setting during Form Open?

Some other things I am noticing related to this:

The list box does select index 0 as expected even with Multi Select is
set to None, just that no controls work. I am only able to switch
back to design view or close access.

During the controls not responding, cpu utilization is 0 so I dont
think any processes are hanging.

If I make a command button whose on click event sets the single select
list box to select index 0, everything works fine.

So this seems to be an issue that happens with the list box set to
Multi Select None during Form Open, but not during other events.

I am merely a novice with Access / VBA so I really don't know where to
begin to correctly deal with this. I do know that the list box in
question must only allow 1 selection at a time and that default
selection really should be index 0.

Please help.
Chas
 
Move the Form_Open event to the first position in the form's code
module. (Ie. do not have any other procedures or unctions before it.)
Then put the following line immediately *after* the "end sub" line of
that event:

#IF FALSE THEN

and add the following line as the very last line in the whole code
module:

#ENDIF

This will have the effect of temporarily commenting-out *all* the code
in the form module, except for the form_load event.

Then try again, twice. Once with multiselect true; again with
multiselect fase. Make ***no other changes***, except for that single
one.

If the alleged buggy behaviour goes away, the problem is actually
somewhere in your code.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
ChasW said:
I believe i stumbled across a bug in access 2000, but I am not sure.
I was hoping somebody here might have an explanation.

I should first mention that my ac2000 is patched to sp3 and the Jet
Engine is patched to the latest version.

Using a listbox in a form with Multi Select set to Extended, the
following code works fine during the Form Open event.

With Me.List27
.RowSourceType = "Value List"
.RowSource = ">=; >; =; <=; <"
.Selected(0) = True
End With

However, if I try to use the same list box with Multi Select set to
None, then at runtime none of the controls on the form are responsive
unless I remove the above line of code:

.Selected(0) = True

Why does a regular list box not want this setting during Form Open?

Some other things I am noticing related to this:

The list box does select index 0 as expected even with Multi Select is
set to None, just that no controls work. I am only able to switch
back to design view or close access.

During the controls not responding, cpu utilization is 0 so I dont
think any processes are hanging.

If I make a command button whose on click event sets the single select
list box to select index 0, everything works fine.

So this seems to be an issue that happens with the list box set to
Multi Select None during Form Open, but not during other events.

I am merely a novice with Access / VBA so I really don't know where to
begin to correctly deal with this. I do know that the list box in
question must only allow 1 selection at a time and that default
selection really should be index 0.


I am wondering if the Open event is too soon to be doing
that. Try moving that code to the Load event.

BTW, there are other ways to preselect an item in a single
select list box. Again no earlier than the Load event, you
could just assign the list box's value to the zeroth
element:
.Value = .ItemData(0)
 
Move the Form_Open event to the first position in the form's code
module. (Ie. do not have any other procedures or unctions before it.)
Then put the following line immediately *after* the "end sub" line of
that event:

#IF FALSE THEN

and add the following line as the very last line in the whole code
module:

#ENDIF

This will have the effect of temporarily commenting-out *all* the code
in the form module, except for the form_load event.

Then try again, twice. Once with multiselect true; again with
multiselect fase. Make ***no other changes***, except for that single
one.

If the alleged buggy behaviour goes away, the problem is actually
somewhere in your code.

HTH,
TC (MVP Access)
http://tc2.atspace.com

With the exception of

Option Compare Database
Option Explicit

The Form_Open event was at the very top of the whole code module (code
for this form)

I placed the #IF FALSE THEN and #ENDIF exactly where you said.

Then I tried both of these settings for the list box: Multi Select
None and Multi Select Extended.

and the behavior still persists for the case of Multi Select None with
this line of code present:

..Selected(0) = True

which is part of this set of lines

With Me.List27
.RowSourceType = "Value List"
.RowSource = ">=; >; =; <=; <"
.Selected(0) = True
End With

I assume this is a bug of some type.

How could I programmatically set the listbox's Multi Select property?

Right now I am doing this setting in the form's design view propery
sheet for the listbox. I am wondering if changing the Multi Select
option later in the code would have any impact, but I haven't been
able to figure out how to set this propery in VBA.

Thanks for working with me on this.
Chas
 
I am wondering if the Open event is too soon to be doing
that. Try moving that code to the Load event.

BTW, there are other ways to preselect an item in a single
select list box. Again no earlier than the Load event, you
could just assign the list box's value to the zeroth
element:
.Value = .ItemData(0)

Marshall thank you.
Moving the listbox code to the load event correct this.

Best Regards,
Chas
 
Can you put that database on the web where I can get a copy?

TC (MVP Access)
http://tc2.atspace.com

Another post in this thread became the solution.
Moving the code from the form open event to the form load event did
the trick.

Thank you for your willingness to look further into this.
Chas
 
Back
Top