subform with more than one blank row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I am creating a data entry form with a subform using access as a front end... I need to create a form for data entry where the user may select a number of records that they wish to enter, and then press a button to have the subform create that many rows for them to submit data, with each row being one record in the database.

So if the schema was something like: "car name, year, price", when the user is asked how many records they want to submit, and they choose three, the form should generate a subform with three rows in it, that they can then enter information for three seperate cars. (and no more than three)

I have no idea how to get the subform to do this... ideally i would like it to be locked at three records too if thats what is selected, so that no extra record can be submitted accidently. Is it better to use a continuous subform or a datasheet? Most people seem to favour a continuous.

I also cannot create any temporary tables on the client side, although a linked table is ok, and would much prefer to use ADO rather than DAO if at all possible. Sorry very little VBA experience :(

thanks for any help!!
 
The BeforeInsert event of a form can be cancelled. So, if you use that
event, you can from somewhere figure out the number of records to allow,
and if that number exists, cancel the event.
I assume that you have a form with the number-control in it, and a
subform where you enter the records. My idea is written as (AIR CODE)

Private Sub Form_BeforeInsert(Cancel As Integer)
Cancel = (DCount("*","yourTable","optional condition")=parent.ctlNumber
End Sub

(it wraps, where it shouldn't.)
-> yourTable is the table with the new records
-> optional condition: use if that table will contain other records, not
having to do with the current data entry
-> ctlNumber: name of the control in the main form

HTH
 
Back
Top