Unbound Checkboxes need to trigger event

G

Guest

Hi Everyone,

I have a form with a set of unbound checkboxes representing dates a building
was in use. I want to use the results from this to fill in the linking table
between 2 tables (buildings and eras). However, I don't want to have to
store all of the values of the checkboxes in one of the individual tables.
I've got the code to do all of this, I'm just not sure where to trigger it
from.

Being the controls are unbound, the Before/After Updates events don't happen
because no record is being updated. I'd like for it to happen when the form
moves to another record, but can't figure out which event this is. The only
other idea I had was for it to happen on the Click event of the checkbox, but
I don't want to have to do that many read/writes to the linking table.

Any ideas? If there's a better way of doing this, I'd appreciate it too.
Thanks!
 
G

Guest

- Why not try the On_Change of the form. This has one drawback because this
is also fired when the user goes to a previous record.

- You could also try placing all your checkboxes in a Option Group and place
a check on the Before_Update of the form to check the value of the
Optiongroup. Based on that outcome you can take the action you want.

- Or you can place a "check" in the tag of the checkboxes and loop through
the controls by checking the tag of the controls. If they match take the
required action else do nothing.

hth
 
G

Guest

Maurice,

Thanks for the tips. I can't seem to find the On_Change event for a form
(the helpfiles only have that for text and combo boxes). Also, unless I'm
reading it wrong, an Option Group can only have one thing selected in it.
The user for my form needs to be able to check multiple checkboxes (a
building could be used in several different time periods), my bad on not
explaining that in the first place.

I haven't used tags before (this is my first big db project). I'm a little
confused as to what sort of check this would be and when I would execute it.

Thanks again
 
G

Guest

Hi Shaun,

The On_Change should be On_Current, my mistake sorry. But you are correct
when stating that in an option group you only can select one item. So this
option is no good for you.

The tags...

Every control has a tag. It's a property where normally nothing is stored
but you can use it. Because you can use it many people do.
So for instance: a textbox has properties (i assume you know how to get
there but just to be sure - rightclick on control in designview and choose
properties)

Now look for the option 'Tag'. I have to say that this is the English word
for it. Depending on your Office lanuguage this might differ. (if you check
the 'other'-tab it is at the bottom).

What you can do is place the word 'chk' (without the quotes) in the tag of
every checkbox.

Now in code write the following for the form:

private sub Form_AfterUpdate
dim ctl as control

'-> Loop through controls

for each ctl in me
if ctl.tag ="chk" then '-> check to see if there's something in the tag
[do your action here...]
end if
next

end sub

hth
 
G

Guest

I've already got something in the On_Current controller (loading up the
current record's checkboxes).

I'm already doing something similar to the tags with the names of the
checkboxes ("Name" LIKE "Era*"), so I don't think that's going to solve the
problem either. Also, you placed the code for that in the "AfterUpdate"
event controller. The event doesn't happen because the checkboxes aren't
bound to a record so no update is taking place.

Is there a way to tie the checkboxes to the linking table so that it knows
an update is needed?

Maurice said:
Hi Shaun,

The On_Change should be On_Current, my mistake sorry. But you are correct
when stating that in an option group you only can select one item. So this
option is no good for you.

The tags...

Every control has a tag. It's a property where normally nothing is stored
but you can use it. Because you can use it many people do.
So for instance: a textbox has properties (i assume you know how to get
there but just to be sure - rightclick on control in designview and choose
properties)

Now look for the option 'Tag'. I have to say that this is the English word
for it. Depending on your Office lanuguage this might differ. (if you check
the 'other'-tab it is at the bottom).

What you can do is place the word 'chk' (without the quotes) in the tag of
every checkbox.

Now in code write the following for the form:

private sub Form_AfterUpdate
dim ctl as control

'-> Loop through controls

for each ctl in me
if ctl.tag ="chk" then '-> check to see if there's something in the tag
[do your action here...]
end if
next

end sub

hth
--
Maurice Ausum


Shaun said:
Maurice,

Thanks for the tips. I can't seem to find the On_Change event for a form
(the helpfiles only have that for text and combo boxes). Also, unless I'm
reading it wrong, an Option Group can only have one thing selected in it.
The user for my form needs to be able to check multiple checkboxes (a
building could be used in several different time periods), my bad on not
explaining that in the first place.

I haven't used tags before (this is my first big db project). I'm a little
confused as to what sort of check this would be and when I would execute it.

Thanks again
 
G

Guest

I get your point. Why not just place a button with the text &Save or
something like that. That way you have control of whenever the action needs
to be taken.

--
Maurice Ausum


Shaun said:
I've already got something in the On_Current controller (loading up the
current record's checkboxes).

I'm already doing something similar to the tags with the names of the
checkboxes ("Name" LIKE "Era*"), so I don't think that's going to solve the
problem either. Also, you placed the code for that in the "AfterUpdate"
event controller. The event doesn't happen because the checkboxes aren't
bound to a record so no update is taking place.

Is there a way to tie the checkboxes to the linking table so that it knows
an update is needed?

Maurice said:
Hi Shaun,

The On_Change should be On_Current, my mistake sorry. But you are correct
when stating that in an option group you only can select one item. So this
option is no good for you.

The tags...

Every control has a tag. It's a property where normally nothing is stored
but you can use it. Because you can use it many people do.
So for instance: a textbox has properties (i assume you know how to get
there but just to be sure - rightclick on control in designview and choose
properties)

Now look for the option 'Tag'. I have to say that this is the English word
for it. Depending on your Office lanuguage this might differ. (if you check
the 'other'-tab it is at the bottom).

What you can do is place the word 'chk' (without the quotes) in the tag of
every checkbox.

Now in code write the following for the form:

private sub Form_AfterUpdate
dim ctl as control

'-> Loop through controls

for each ctl in me
if ctl.tag ="chk" then '-> check to see if there's something in the tag
[do your action here...]
end if
next

end sub

hth
--
Maurice Ausum


Shaun said:
Maurice,

Thanks for the tips. I can't seem to find the On_Change event for a form
(the helpfiles only have that for text and combo boxes). Also, unless I'm
reading it wrong, an Option Group can only have one thing selected in it.
The user for my form needs to be able to check multiple checkboxes (a
building could be used in several different time periods), my bad on not
explaining that in the first place.

I haven't used tags before (this is my first big db project). I'm a little
confused as to what sort of check this would be and when I would execute it.

Thanks again

:

- Why not try the On_Change of the form. This has one drawback because this
is also fired when the user goes to a previous record.

- You could also try placing all your checkboxes in a Option Group and place
a check on the Before_Update of the form to check the value of the
Optiongroup. Based on that outcome you can take the action you want.

- Or you can place a "check" in the tag of the checkboxes and loop through
the controls by checking the tag of the controls. If they match take the
required action else do nothing.

hth
--
Maurice Ausum


:

Hi Everyone,

I have a form with a set of unbound checkboxes representing dates a building
was in use. I want to use the results from this to fill in the linking table
between 2 tables (buildings and eras). However, I don't want to have to
store all of the values of the checkboxes in one of the individual tables.
I've got the code to do all of this, I'm just not sure where to trigger it
from.

Being the controls are unbound, the Before/After Updates events don't happen
because no record is being updated. I'd like for it to happen when the form
moves to another record, but can't figure out which event this is. The only
other idea I had was for it to happen on the Click event of the checkbox, but
I don't want to have to do that many read/writes to the linking table.

Any ideas? If there's a better way of doing this, I'd appreciate it too.
Thanks!
 

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