Unable to Select Option in List Box that has been made Visible by

A

AlwaysFroosh!

I have a list box that starts out invisible, and is changed to visible via
code in the forms on load event if certian criteria are met. If these
criteria are met, the listbox does become visible, but no options can be
selected. The list box's enabled property is true because it is not greyed
out, and I'm pretty sure the locked property is false because it can get
focus and has the little dotted line border around the option. But still the
option is not selected. If I try to use the list box's onclick even to
display a message box, nothing happens when the list box is clicked on.

Does anyone have any ideas where I'm going wrong?

Thanks,
Graham
 
J

Jeff Boyce

Have you tried requerying the listbox?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

JonWayn

I am not quite sure what you mean by the options cant get selected. When you
click an item with the mouse, does the item get highlighted? If it does, make
sure that the listbox is attached to its AfterUpdate or Click event. To do
so, switch to the form and ensure that either event is set to [Event
Procedure] in the property sheet
If instead you are using the OnClick property to programatically attach the
object with the event; make sure the procedure you are calling is a Function
procedure and not a Sub. Also, if the Function is declared as "Function
ShowMsg()", then the setting of the OnClick property should be
ListBoxName.OnClick = "=ShowMsg", and NOT ListboxName.OnClick = "ShowMsg" -
note the inclusion of the equal (=) sign as part of the setting.
 
A

AlwaysFroosh!

Thanks for the reply Jeff. I did try requerying the listbox, but that did not
help.

Graham
 
A

AlwaysFroosh!

When I click on the listbox, nothing gets highlighted. ONE of the items in
the list will get the focus border around it, but it doesn't matter where I
click, I can't change which item gets the focus border.

You are correct that the procedure I'm calling is a sub, not a function. But
when I changed it to a function and compile it I get the following messages:

"Compile error:

Procedure declaration does not match description of event or procedure
having the same name."

The code that I had before looks like this:

Private Sub Discrepancy_Lists_Click()
MsgBox Me.Discrepancy_Lists.Value
End Sub



JonWayn said:
I am not quite sure what you mean by the options cant get selected. When you
click an item with the mouse, does the item get highlighted? If it does, make
sure that the listbox is attached to its AfterUpdate or Click event. To do
so, switch to the form and ensure that either event is set to [Event
Procedure] in the property sheet
If instead you are using the OnClick property to programatically attach the
object with the event; make sure the procedure you are calling is a Function
procedure and not a Sub. Also, if the Function is declared as "Function
ShowMsg()", then the setting of the OnClick property should be
ListBoxName.OnClick = "=ShowMsg", and NOT ListboxName.OnClick = "ShowMsg" -
note the inclusion of the equal (=) sign as part of the setting.


AlwaysFroosh! said:
I have a list box that starts out invisible, and is changed to visible via
code in the forms on load event if certian criteria are met. If these
criteria are met, the listbox does become visible, but no options can be
selected. The list box's enabled property is true because it is not greyed
out, and I'm pretty sure the locked property is false because it can get
focus and has the little dotted line border around the option. But still the
option is not selected. If I try to use the list box's onclick even to
display a message box, nothing happens when the list box is clicked on.

Does anyone have any ideas where I'm going wrong?

Thanks,
Graham
 
J

Jeff Boyce

You don't mention which version of Access you are using.

There have been some problems with apparently empty comboboxes and listboxes
after folks apply the SP3 update for Office 2003. Any chance that could be
a factor? (There's a hotfix at Microsoft if so...).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
A

AlwaysFroosh!

Yup, that could definitely be it. We are using Access 2003 SP2, so maybe
that's my problem.

Oh well, I thought of a suitable workaround. Instead of having the list box
appear on the main form if the criteria are met, it simply makes a message
appear and a button that loads another form with the populated list box on
it. The criteria that makes this visible is a discrpancy in two pieces of
data in our database, so I need our users to be made aware of the discrepancy
when the form loads so they can go and fix it. The button works, it's pretty
obvious when it becomes visible.

Thanks for your help,
Graham
 
D

Doug

I had the same problem. It turns out, it's because the Allow Edits property
of the form was set to no. Not sure that makes sense, but setting it to yes
fixed the issue.

-Doug

AlwaysFroosh! said:
When I click on the listbox, nothing gets highlighted. ONE of the items in
the list will get the focus border around it, but it doesn't matter where I
click, I can't change which item gets the focus border.

You are correct that the procedure I'm calling is a sub, not a function. But
when I changed it to a function and compile it I get the following messages:

"Compile error:

Procedure declaration does not match description of event or procedure
having the same name."

The code that I had before looks like this:

Private Sub Discrepancy_Lists_Click()
MsgBox Me.Discrepancy_Lists.Value
End Sub



JonWayn said:
I am not quite sure what you mean by the options cant get selected. When you
click an item with the mouse, does the item get highlighted? If it does, make
sure that the listbox is attached to its AfterUpdate or Click event. To do
so, switch to the form and ensure that either event is set to [Event
Procedure] in the property sheet
If instead you are using the OnClick property to programatically attach the
object with the event; make sure the procedure you are calling is a Function
procedure and not a Sub. Also, if the Function is declared as "Function
ShowMsg()", then the setting of the OnClick property should be
ListBoxName.OnClick = "=ShowMsg", and NOT ListboxName.OnClick = "ShowMsg" -
note the inclusion of the equal (=) sign as part of the setting.


AlwaysFroosh! said:
I have a list box that starts out invisible, and is changed to visible via
code in the forms on load event if certian criteria are met. If these
criteria are met, the listbox does become visible, but no options can be
selected. The list box's enabled property is true because it is not greyed
out, and I'm pretty sure the locked property is false because it can get
focus and has the little dotted line border around the option. But still the
option is not selected. If I try to use the list box's onclick even to
display a message box, nothing happens when the list box is clicked on.

Does anyone have any ideas where I'm going wrong?

Thanks,
Graham
 

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