insert rows in a table using quantity field

W

Wayne-I-M

Hi Deepak

The table is not sorted in that way - ok i "can" be but best to ignor the
table to start.
I want that, a user has to enter the fields(pop-up);

1st create a new form with your primary field (this can be hidden if you
don't need users to see it - this is a "very" good idea).
On your new form (call it frmEntry) put these fields
ID field
serialnumber
quantity

Then on your main form place a new button (call it ButtonEntry) with this
behind the OnClick event

Private Sub ButtonEntry_Click()
DoCmd.OpenForm "frmEntry", , , "[IDField]=" & Me.IDField
End Sub


Note the above code assumes that IDField is a number ??
Change the IDField name to what it is on your forms (it may be different
from the table name??)

Then, I want output in the table as:
Don't do this. Create a query (if you don't already have one) and sort by
your serialnumber field ascending. Use this query to produce reports/view
results/etc.


Hope this helps
 
G

Gerwin Berentschot

First, in your example 6 record are created when the user enters a quantity
of 5. You might consider to create the number of records the user entered
(5=5, 6=6, etc.).

Second, my guess is that it is not necessary to store the quantity in de
table. It is only used once when creating the new records, am I right?

To create the new records in your table you could do it like this:
1. Create a form with two fields, fldSerialnumber and fldQuantity. Add an OK
button. Do not make this form databound!
2. In the on click event of the OK button put the following code:
dim rs as dao.recordset
set rs=currentdb.openrecordset("YourTableName")
for i = 0 to fldQuantity - 1
with rs
.addnew
!Serialnumber = fldSerialnumber + i
.update
end with
next i
set rs = nothing

Note: this code assumes you want to create the number of records the user
entered (see my first remark)!

You will have to create another databound form to view and edit the records
created.

Hope I helped you with this.
 
D

Deepak Verma

Dear all

I've made two numeric fields in access table.

1. serialnumber
2. quantity
I want that, a user has to enter the fields(pop-up);
Enter serial number; Enter quantity
Example : 1000, 5

Then, I want output in the table as:
1000
1001
1002
1003
1004
1005

please help

Thanks and Regards

Deepak
 

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