Checkbox Form-Table VBA Update Code

jivins1215

New Member
Joined
Aug 11, 2016
Messages
2
I have a database tracking whether employees attend their meetings. For every meeting they attend they get paid. The attendance sheets get submitted by an upload form into my database as a Form with checkboxes for each employee. Now I want my VBA code to see that if the "AttndMeeting1" value is checked for an employee to also automatically check the corresponding "Paid1" value for the same employee. I also want the all the "AttndMeeting" and "Paid" fields on the form to be copied onto my MasterList of employees, which is in a table on the database. Since "AttndMeeting1" is a column on the table and form, there has to be a way for it to automatically pull from the form to the table, right?

This is what I have so far. The "Master_List" is the master list. I know I have a long way to go.

Sub UpdatePaidCheckbox()
Dim i As Integer
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Master_List")
For i = 0 To rs.RecordCount - 1
If rs.Fields("AttndMeeting1") = "Yes" Then
rs.AddNew
rs.Fields("Paid1") = "Yes"
rs.Close
Set rs = Nothing
db.Close
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Is this form bound? If so, to what? If it's a table or an updatable query, you're making this way too complicated.
If it's not, you should have a good reason why.
I have to also presume the Paid checkbox is not visible (or will not be when your form design is completed), otherwise why code to set this when someone could simply check it as well as the Attended one? In that case, the update event of the Attended checkbox should be used to set the Paid to True and vice-versa if someone decides that checking the Attended was a mistake. If the form is bound, the record is updated. When that happens exactly depends on the style of form you've created.
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,766
Members
449,336
Latest member
p17tootie

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top