Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox

Status
Not open for further replies.

Judalie

Programmer
Mar 25, 2002
40
0
0
US
I have a form that shows records in a tabular format.. I have a Checkbox at the beginning of each record.. I want the checkbox to be false on opening the form. If I set the checkbox to false on click of the commandbutton which opens the form, the first record is false but other records show the checkbox (if it was checked before)..still true... while this has no effect on my data...(if you want to make the action which happens if the checkbox is true, you have to uncheck it and then check it) this is not good because it will confuse my users...please help!!!

thanks so much!!!
j
 
I'm not sure I would have used a checkbox (yes/no field) within the record for this purpose, but anyway, what you should do is run an Update query before you do the OpenForm. Something like this:
Code:
    DoCmd.SetWarnings False
    DoCmd.RunSQL &quot;UPDATE <tablename> SET <chkboxfield> = False&quot;
    DoCmd.SetWarnings True
    DoCmd.OpenForm ...

The SetWarnings will prevent the confirmation dialog &quot;You are about to update xxx rows...&quot;. The SQL statement sets the field to False, and since it has no WHERE clause it applies to all the rows. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Rick:
Thanks .... I have the form2 opened when another form1 is open and have a field that needs to be set to a matching field in opened form1...so i use the checkbox in the record (listed in tabular form)..scroll down and check the checkbox to get the fields that i choose to set my field in opened form1.. what mechanism would you use to make this happen?... a command button maybe?
thanks
j
 
A command button seems like the right approach. Of course, the check box, being data bound, was associated with a specific record, while a command button would work on whatever record was current, so with the command button they have to select the desired row in the form2 first, and then click the button. That seems a little inconvenient, perhaps.

But here are a couple of tricks you can use. One, you can display the rows in a subform (unlinked) within form2. You can display the subform in form view, but design it to look very similar to a datasheet. That lets you put a little square command button on each row. You could even put a check mark on the button if you want. :)

Second, you could do the same, but instead of putting a visible command button on the subform detail, put a transparent button on top of the whole row. Then the user can click anywhere on the row to update it. (Caution: This might make it too easy to make mistakes, too!) Note that this isn't appropriate if they can edit any of the fields; if you cover them all with the transparent command button, they won't be able to edit anything. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top