Add New Records Based on Value in Text Box

M

monkra

I have a table rcalled Records, with the fields
ID (Autonumber)
RecordNum (long int)

and a form called FormRecords with this table as its source.

I have another unbound form called FormInput, with a textbox called TextNum
and a command button called CommandNum. I want to put a number in TextNum,
click CommandNum and have that open FormRecords and add as many new records
as the number in TextNum.

I have no ide how to do this, and any help would be greatly appreciated.

Thanks,
monkra
 
J

John W. Vinson

I have another unbound form called FormInput, with a textbox called TextNum
and a command button called CommandNum. I want to put a number in TextNum,
click CommandNum and have that open FormRecords and add as many new records
as the number in TextNum.

Ummmm... WHY?

It sounds like you're creating an arbitrary number of identical records,
differing only in the value of an autonumber. What purpose do these records
serve? If they're intended to be edited later, it's *very* rarely a good idea
to do so - such "placeholder" records have a nasty way of never getting filled
in.

That said... you can create a little auxiliary table Num with one Long Integer
field N, filled with values from 0 through the largest TextNum you'll ever use
(be generous). You can base an Append query on Num:

INSERT INTO yourtable(fieldname)
SELECT N+1 FROM Num
WHERE N < [Forms]![FormInput]![TextNum];

Note that you're inserting records *into a table*, not into a form; forms
don't contain records, they're just windows which let you edit data stored in
a table.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top