Originally Posted by
Jojojo
I would like to control/limit the number of records that can be entered into a subform based on a choice the user makes in the main form
There is a combo box called FeeScheduleID on the main form. There are 8 choices. I'd like, if the user chooses option 1, they can only add 1 record. If they choose option 2, they shave to enter 2 records, up to 5. The last 3 choices I would like not to have a limit. The subform is data sheet style, where the user selects their class option from a combo box.
With the main form in design mode, add a textbox and set its visible property to false.
Assume its name is 'TextBox20.
Then select 'FeeScheduleID' and look at its property sheet. You should see a "Click" event. On the right of that line is an ellipsis (...). Click on the ellipsis and select VBA code. The VBA screen should appear with
Sub FeeScheduleID_OnClick()
End Sub
Insert something like this:
TextBox20.value = FeeScheduleID.Option ' This will depend on details of your combo box
If TextBox20.value > 5 then Textbox20.value = 1000
You've set the maximum number of records allowed.
Right now the form/subform is fully functional, it just doesn't control the number of records that can be entered and I'm noticing a lot of user error, like choosing option 2 and entering 1 or 3 records then in the subform. have no idea how to do the code on this. I thought it would be like an if then statement??