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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check or Clear a Checkbox Automatically

Status
Not open for further replies.

davo

Technical User
Aug 7, 2000
29
0
0
US
When I check a checkbox in one table, I would like to have a checkbox in another table automatically checked.&nbsp;&nbsp;The first table, Docs in Progress, has the optional field Library Number and the checkbox Revision.&nbsp;&nbsp;The second table, Library Index has the primary key field Library Number and the checkbox Under Revision.&nbsp;&nbsp;If I enter a Library Number in the first table that matches the number in the second table and I check the Revision checkbox, I would like the Under Revision checkbox automatically checked.&nbsp;&nbsp;And, if I delete the record or just the number in the first table, the Under Revision checkbox should then be automatically cleared.<br>I would like to achieve this without using an update query.&nbsp;&nbsp;Can I do this with a bit of code in the Code Builder in Form design?&nbsp;&nbsp;Can anyone give me a sample of code to use?&nbsp;&nbsp;Thanks.<br>
 
Yes!!!!<br><br>You have to decide on the trigger point.<br><br>open a recordset<br>On Error goto Err_Myfunction<br> Dim db as database, rst as recordset, SQL as string<br> Set db = CurrentDb<br> ' SQL string.<br> SELECT FirstTable.Library Number, FirstTable.Library Number <br>FROM FirstTable INNER JOIN SecondTable ON FirstTable.Library Number = SecondTable.Library Number; Set rst = db.OpenRecordset(SQL)<br>rst.movelast ' If there is no match then an error will occur.<br>' you could trap that error and then use it to check or uncheck your boxes<br>rst![Under Revision] = True 'Check the box<br>rst.close<br>db.close<br><br>Exit_Myfunction<br>exit function<br><br>Err_Myfunction:<br> select case err.number<br> Case 3021<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' No current record<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' you have to open a another record set and find the record to make [Under Revision] =true or false<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Error # &quot; & Err.Number & &quot;&nbsp;&nbsp;&quot; &Err.Description, vbInformation, &quot;In sub Myfunction<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resume Exit_Myfunction<br>&nbsp;&nbsp;&nbsp;&nbsp;End Select<br><br><br><br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top