Click Subform To Run Code

  • Thread starter Thread starter Sally
  • Start date Start date
S

Sally

I need to be able to click in a subform and run code but at the same time I
need to be able to scroll the records without running the code. I tried
coding the Enter event of the subform control but when I try to scroll the
records the code runs. The subform is continuous; all the controls are on
one line and the detail section is not exsposed above or below the controls.
I tried coding the detail Click event but nothing happened. I tried coding
the Enter event of the controls and that worked when I clicked on a control.
The problem with that though is that the code doesn't execute when there are
no records or when I click in the white area after the last record. I'm
looking for suggestions!

Thanks,

Sally
 
Thanks for responding, Ken,

Yes, there are forty two small subforms on the main form and the code needs
to know which one was clicked on. Clicking on any subform returns a value
that is specific to that subform.

Sally
 
You're saying there is no room for a command button on the subforms then?

The "click" event for a form occurs only if you click on the record selector
(if it's visible). And from your description, if you don't want to code
click events of every control on the subforms, then you'll need a different
approach.

Are the subforms' values/textboxes just for display? If you don't let the
user edit them, then you could put a single, transparent command button
across and on top of all the controls in a subform; and then use the click
event of that button to run your code.

--

Ken Snell
<MS ACCESS MVP>
 
Yes, there is no room for a command button.
Yes, the textboxes on the subforms are only for display.

If I go with the command button, what happens when I scroll the records in
any subform and click in the area below the last record; I will be off the
command button? This is the reason for my post before this one. I am asking
if there is a way to code a click event for that area. That problem is
extenuated because there will only be one command button and hense most of
the area in the subform will not be covered by a command button.

Also, Allow Additions is set to False in the subforms.

To picture what I have better, the subforms are arranged like a calendar.

Sally
 
What I suggest is that you put the command button across the entire detail
section of the subform. That way, the button is available for all the
displayed records.

Because you have the subform set to not allow additions, there is no "extra"
record at the bottom, so there will not be a command button there. I don't
know what the "white space" is at the bottom of your subform...is the
subform's form footer?
--

Ken Snell
<MS ACCESS MVP>
 
Ken,

Thanks for staying with me on this! I found the solution. See my last post
in my previos thread Subform "White Areas".

Sally
 
Back
Top