CheckBox Help

G

Guest

I have a Main form. On this main form, I have 4 check boxes that I want when
checking off to stamp a date on a subform date field. When I check one of
the check boxes I want the date I check the checkbox to be entered
automatically in the subform field date. When I uncheck the checkbox I want
the date to be removed. Can someone please help me. Thank you in advance
for any help will be greatly appreciated.
 
R

Ron2006

some important questions, because they determines how the process can
be done, is:

1) Is there or can there be more than one record in the subform? I am
not asking if you can see more than one but if you changed the subform
to be in datasheet view, how may records would / could be selected/
shown.

2) When you check this checkbox on the main form, are the date fields
in ALL records in the subform to be changed or only the date in the
one record that is selected in the subform.?

Ron
 
G

Guest

Thank you for answering. My subform is in datasheet view and yes there can
be more than one record. There could be from one to maybe 10 records. Yes
 
R

Ron2006

One way or the other you will need to create a query for each of the
buttons

The queries must select the same records that your subform query
selects. and be update queries for the appropriate date field. If you
create a hidden date field (unbound) on your form and have the
quieries use that field to update with. Then basically each of the
check boxes will have the following code in the afterupdate event.

if me.chkbx1 = true then
me.hiddenfield = me.datetouseforupdate
docmd.setwarnings false
docmd.runquery "Query for field1 update"
docmd.setwarnings true
else
me.hiddenfield = null
docmd.setwarnings false
docmd.runquery "Query for field1 update"
docmd.setwarnings true
endif
me.subformname.requery ' although me.subformname.repaint
may also work.

If you get errors on the update with the null value you may need to
create a separate update to update with null as a part of the query.
In that case you would run one or the other queries depending on the
value in the chkbx.

The same type of logic needs to be in each checkbox afterupdate event.

If you save the query that is used as the rowsource as a specific
query name then you can use that query as the base table/query for the
update queries (Another good reason for saving queries as queries
instead of being hidden in the form/subform.)

Ron
 
R

Ron2006

If it was only the field of the subform record that was selected then
you could use something like this

if chkbx1 = true then
me.subformname.form.datefieldtobeupdatedname =
me.datetousetoupdate
else
me.subformname.form.datefieldtobeupdatedname = null
endif
me.subformname.repaint

Ron
 

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

Similar Threads

Updating tables when you input new data 0
Update Checkbox 3
Turn checkbox on and off 1
timestamp 3
Subform - Access 2003 2
Checkbox Question 6
Form/subform checkbox Question 1
Subform does not display 6

Top