Art said:
Hi,
I need to do it by using code. I have a command buton in a form which will
start the code (command_click()). Say I have fields "number", "name" in
table t1. I want to add 10 new records automatically with the command button
clicking. The fields woulb be filled like:
number------name
100---------Tom
101---------Tom
102---------Tom
......
......
......
110---------Tom
I'll appreciate having your answer. Regards.
Steve's answer is still the solution.
If you really just want a sequence n to n+9 inclusive, where n is the next
number available, you would just make this field be an autonumber field and just
run the append query 10 times. In this case you create the query as an append
query just as if you were going to run it manually, and to run it in code use
the docmd.OpenQuery method.
If you specifically want the numbers to be 100-109, the process is similar, but
in this case you use docmd.RunSQL instead and code in the 100-109 values one at
a time. (You could do this above also if you prefer). To create the SQL, just
use the wizard to create the same query as described above, then from design
view switch to SQL view to see the SQL. The statements you see will execute the
same query when ginen to the docmd.RunSQL method as a string. So you can just
modify the string for the numbers 100-109, one at a time (in a for-next loop)
and rerun the docmd.RunSQL (String_Of_SQL_Code_Here).
gm