Adding Multiple Records

  • Thread starter Thread starter SDCT
  • Start date Start date
S

SDCT

Hi,

I am attempting to add multiple records to a table from a command
button. All but one of the fields will be the same for each record. I
have checkboxes with user names, and I'd like to add a record for each
user that is checked. The form is unbound - with textboxes that will
hold the standard information for each record. I just need to add
separate records based on whether the user's checkbox is checked...

if chkbox.value = -1 then
docmd.runsql "insert into..."


I'm having trouble setting up the loop and/or recordset. Any guidance
is greatly appreciated.

Thanks
 
Name your check boxes 'chk1','chk2', etc. In the tag property for each box,
store the name of the person that the check box is for. Then you can use
something like the following code to loop through them. Note: I have used
this successfully for combo boxes, but never for check boxes. It should still
work.

Dim intCurBox as integer

For intCurrentBox = 1 To << how ever many boxes you have>>
If Me("chk" & intCurBox).Value = -1 Then
<< do something here; use Me("chk" & intCurBox).Tag to get the name
of the person>>
End If
Next intCurrentBox
 
Thanks a lot.... a much simpler approach than I expected, and it does
exactly what I need it to do!!! Much appreciated!!!
 
Back
Top