Well, this should be easy... But I'm doing something wrong and can't find anything in the forum as an example.....
I have a Form for creating an invoice billing for segments of time spent on a project. This form (frmInvoice) has a subform
(frmHoursTimeInvoice) This subform has 2 checkboxes, one for "Billed" (HoursBilled) and one to include unbilled time into the invoice total (InvoiceHours)
So... When you open the form to create an invoice the subform shows only unbilled hours.... as you ckeck the boxes (InvoiceHours) it adds the time to the invoice and calculates the total... So far so good........ Now the problem. I attached a "Close" command button to test this code....
Private Sub cmdCloseSave_Click()
On Error GoTo Err_cmdCloseSave_Click
If [frmHoursTimeInvoice].Form![InvoiceHours] = True Then
[frmHoursTimeInvoice].Form![HoursBilled] = True
Else
If [frmHoursTimeInvoice].Form![InvoiceHours] = False Then
[frmHoursTimeInvoice].Form![HoursBilled] = False
End If
End If
DoCmd.Close
Exit_cmdCloseSave_Click:
Exit Sub
Err_cmdCloseSave_Click:
MsgBox Err.Description
Resume Exit_cmdCloseSave_Click
End Sub
Now the problem is after it marks the first record (HoursBilled) True... it stops executing the code. I know it needs a loop here.... But I cannot find an example that works!! It needs to loop through all of the records in the subform and check the correct boxes True and leave the others False.
So whats the best method? AND the correct syntax! Would a "For each... (something).... Next" work here??
Thanks!
PS.... Sorry for the lengthy explanation
I have a Form for creating an invoice billing for segments of time spent on a project. This form (frmInvoice) has a subform
(frmHoursTimeInvoice) This subform has 2 checkboxes, one for "Billed" (HoursBilled) and one to include unbilled time into the invoice total (InvoiceHours)
So... When you open the form to create an invoice the subform shows only unbilled hours.... as you ckeck the boxes (InvoiceHours) it adds the time to the invoice and calculates the total... So far so good........ Now the problem. I attached a "Close" command button to test this code....
Private Sub cmdCloseSave_Click()
On Error GoTo Err_cmdCloseSave_Click
If [frmHoursTimeInvoice].Form![InvoiceHours] = True Then
[frmHoursTimeInvoice].Form![HoursBilled] = True
Else
If [frmHoursTimeInvoice].Form![InvoiceHours] = False Then
[frmHoursTimeInvoice].Form![HoursBilled] = False
End If
End If
DoCmd.Close
Exit_cmdCloseSave_Click:
Exit Sub
Err_cmdCloseSave_Click:
MsgBox Err.Description
Resume Exit_cmdCloseSave_Click
End Sub
Now the problem is after it marks the first record (HoursBilled) True... it stops executing the code. I know it needs a loop here.... But I cannot find an example that works!! It needs to loop through all of the records in the subform and check the correct boxes True and leave the others False.
So whats the best method? AND the correct syntax! Would a "For each... (something).... Next" work here??
Thanks!
PS.... Sorry for the lengthy explanation

Last edited: