No need to appologize for for novice-ness. We were all a novice at one point.
Hopefully we get beyond it.
Combo box and list box programming are similar, and use the same basic logic.
Every object on a form has a Property Sheet that houses all the properties
and methods available for that object. Take a look at the Property Sheet for
your list box and you'll see a listing for "On Update." If you put code in
there, it will run every time you select a report. Putting the code
Me.cmdCommandButton.Enabled = True
Me.cmdCommandButton.SetFocus
in that event will permit the user to click on the command button. Putting
the code
Me.lstListBox.SetFocus
Me.cmdCommandButton.Enabled = False
in the command button's OnClick event - after the code that runs the report -
will prevent the user from clicking on the command button again until another
report is selected.
The last line in my previous posting was by way of explaining why I said to
set focus to the list box first, and then disabling the command button. The
reason is that if you only have the line
Me.cmdCommandButton.Enabled = False
without the line
Me.lstListBox.SetFocus
you would get an error "You cannot disable a control that has the focus."
(Yes, I got that message many times, until I remembered it. Remember what I
said about my having been a novice once?) That's why you need to code those
two lines in that particular order.
By the way, if you're unfamiliar with any of these commands or objects, don't
hesitate to consult the Help files. They're well written (arguably), and
that's what they're there for. (And they're also a good vehicle to upgrade
your knowledge.)
Hope this helps,
Sam
erick-flores said:
Thanks for answering to my question. But I still lost I try to do what
you told me but I got confused
"and in the combo box's OnUpdate event (ie, there's a report selected),
re-enable and then set focus to the command button. In the command
button's OnClick event, after running the report, SetFocus to the combo
box and disable the command
button again. This is because you can't disable a control that has the
focus"
I did not get that. I am using a List Box not a combo box. I do not
what you mean by SetFocus and disable the command button again. If you
can give me some feedback I will aprecciated and sorry for been a
novice
Thanks
I would do it slightly differently. I would keep the command button disabled
(add the line cmdButtonName.Enabled = False to the form's Open event), and in
[quoted text clipped - 19 lines]