Which event shall I use?

  • Thread starter Thread starter Niklas Östergren
  • Start date Start date
N

Niklas Östergren

Hi!

I have a QBF (unbound form) with some checkboxes on and a couple of cmd:s. I
have set propertie <Enable> for one cmd to *False* as default. Now I want to
set <Enable = True> if any of the checkboxes is checked (-1). I have a
couple of cmd´s more that I will do the same thing with, on the same form,
later on.

No to my Q:
Which event shall I use on the unbound form?

I know a couple of ways to do this on but I don´t like any of them. The
first one is to check every checkbox status in each checkbox click_event.
This will be a lot of places with the sam check = lot´s of code.

Another way is to create a function which I call from the same event in each
checkbox. A little less code but still much for a simple task as this!

Any idéas?

TIA!
// Niklas
 
there are SOOO many events you CAN use, pick any one that works

I would write One sub to do the enabling, call it something (MySub) , then on the AFTERUPDATE event on each of the criteria (checkbox) controls I would have one line

Call MySub(

Many controls, many events, one su

HTH bl
 
Well, if it was a bound form I could use anyone. But now it´s a unbound form
and there are no records beening updated, which was why I asked. I have
already tryed Afterupdate_Event but it doesn´t work!

So my Q still stand´s but thanks for giving it a shot!

// Niklas
 
Niklas said:
I have a QBF (unbound form) with some checkboxes on and a couple of cmd:s. I
have set propertie <Enable> for one cmd to *False* as default. Now I want to
set <Enable = True> if any of the checkboxes is checked (-1). I have a
couple of cmd´s more that I will do the same thing with, on the same form,
later on.

No to my Q:
Which event shall I use on the unbound form?

I know a couple of ways to do this on but I don´t like any of them. The
first one is to check every checkbox status in each checkbox click_event.
This will be a lot of places with the sam check = lot´s of code.

Another way is to create a function which I call from the same event in each
checkbox. A little less code but still much for a simple task as this!


You can set all of the check boxes' OnClick property to a
function call (instead of [Event Procedure]) so that you
don't have to create a separate event procedure for each
check box. E.g.

=CheckEnable()
 
Hmm, sorry but my english isn´t that good! I don´t quit follow you!
Are you saying I should create a subprocedure that check all checkboxe´s
clickevent and from the same procedure set the cmd´s enable propertie, or
what???

This is probably NOT what you suggest it has to be my missunderstanding you.
Or maby I don´t follow the logic here!

Please explain what you try to say!

TIA!

// Niklas


Marshall Barton said:
Niklas said:
I have a QBF (unbound form) with some checkboxes on and a couple of cmd:s. I
have set propertie <Enable> for one cmd to *False* as default. Now I want to
set <Enable = True> if any of the checkboxes is checked (-1). I have a
couple of cmd´s more that I will do the same thing with, on the same form,
later on.

No to my Q:
Which event shall I use on the unbound form?

I know a couple of ways to do this on but I don´t like any of them. The
first one is to check every checkbox status in each checkbox click_event.
This will be a lot of places with the sam check = lot´s of code.

Another way is to create a function which I call from the same event in each
checkbox. A little less code but still much for a simple task as this!


You can set all of the check boxes' OnClick property to a
function call (instead of [Event Procedure]) so that you
don't have to create a separate event procedure for each
check box. E.g.

=CheckEnable()
 
Niklas said:
Hmm, sorry but my english isn´t that good! I don´t quit follow you!
Are you saying I should create a subprocedure that check all checkboxe´s
clickevent and from the same procedure set the cmd´s enable propertie, or
what???

This is probably NOT what you suggest it has to be my missunderstanding you.
Or maby I don´t follow the logic here!


The OnClick PROPERTY is where you specify the event handler.
You can specify one of three different things in an event
property:

a macro name

[Event Procedure] or whatever that translates to in
your language version

a function name preceeded by an = and followed by ().

You can use the same =functionname() in all of the check
boxes OnClick property, so there is no need to have a
separate event procedure for each check box.
--
Marsh
MVP [MS Access]


Niklas said:
I have a QBF (unbound form) with some checkboxes on and a couple of cmd:s. I
have set propertie <Enable> for one cmd to *False* as default. Now I want to
set <Enable = True> if any of the checkboxes is checked (-1). I have a
couple of cmd´s more that I will do the same thing with, on the same form,
later on.

No to my Q:
Which event shall I use on the unbound form?

I know a couple of ways to do this on but I don´t like any of them. The
first one is to check every checkbox status in each checkbox click_event.
This will be a lot of places with the sam check = lot´s of code.

Another way is to create a function which I call from the same event in each
checkbox. A little less code but still much for a simple task as this!

"Marshall Barton" skrev
You can set all of the check boxes' OnClick property to a
function call (instead of [Event Procedure]) so that you
don't have to create a separate event procedure for each
check box. E.g.

=CheckEnable()
 
First of all, you are miss-informed. The after update event of a check box
DOES FIRE if the control is un-bound (and course even if the form is
un-bound).

So, use the after update.

As mentioned, if you have ten controls where you want this code to
fire..then in place of opening up the code editor for 10 controls and
placing a call to your function like:

MyCheckBoxCode

You can simply highlight all ten boxes at once, and then type in the
function name like:

=MyCheckBoxcode()

So,what Marshal was suggesting is that you do NOT have to open up the code
editor for each control, but JUST PLACE THE NAME of the function in the
property sheet. (in our case..the after update event).

You also have to declare this common function as public for this work (but,
you can leave the code routine in the forms code module).
 
Ok, NOW I get it! Thanks, this wasn´t anything new to me it was just that I
didn´t understand what you where talking about! I have used it before but
didn´t think of it!

Thank´s a lot for your help!

// Niklas


Marshall Barton said:
Niklas said:
Hmm, sorry but my english isn´t that good! I don´t quit follow you!
Are you saying I should create a subprocedure that check all checkboxe´s
clickevent and from the same procedure set the cmd´s enable propertie, or
what???

This is probably NOT what you suggest it has to be my missunderstanding you.
Or maby I don´t follow the logic here!


The OnClick PROPERTY is where you specify the event handler.
You can specify one of three different things in an event
property:

a macro name

[Event Procedure] or whatever that translates to in
your language version

a function name preceeded by an = and followed by ().

You can use the same =functionname() in all of the check
boxes OnClick property, so there is no need to have a
separate event procedure for each check box.
--
Marsh
MVP [MS Access]


Niklas Östergren wrote:
I have a QBF (unbound form) with some checkboxes on and a couple of cmd:s. I
have set propertie <Enable> for one cmd to *False* as default. Now I
want
to
set <Enable = True> if any of the checkboxes is checked (-1). I have a
couple of cmd´s more that I will do the same thing with, on the same form,
later on.

No to my Q:
Which event shall I use on the unbound form?

I know a couple of ways to do this on but I don´t like any of them. The
first one is to check every checkbox status in each checkbox click_event.
This will be a lot of places with the sam check = lot´s of code.

Another way is to create a function which I call from the same event
in
each
checkbox. A little less code but still much for a simple task as this!

"Marshall Barton" skrev
You can set all of the check boxes' OnClick property to a
function call (instead of [Event Procedure]) so that you
don't have to create a separate event procedure for each
check box. E.g.

=CheckEnable()
 
Well we are, or rather where, talking about two different things! I was
talking of the form´s AfterUpdate_Event and this was what I was refering to
when Brainlord answered. Obviously I missunderstod him which wasn´t my
intention. And this will probably explain my snswere to him!?

Now, after reading Marshall´s and your answere I DO understand. It was just
that I didn´t quit follow the english language. I have used this method
before. But I didn´t think of it this time!

Thank´s a lot for helping out!

// Niklas
 
Yes, and even unbound form does as well. But it seams that this event never
fires in an unbound form since there isn´t any recordsource that needs or
can be updated.

At least could´nt I get this event to fire on the form. On the control´s
isn´t any problem there it WILL fire. But my Q was about the form or rather
how to solve my problem.

Thank´s to helpful people I got it to work!

// Niklas
 
Back
Top