Filling certain fields with pre-determined "ranges"

J

Jay

Hi, I was wondering if someone could please help? I've got a table with the
following Fields:

tblJobNos
JobNos: Prim Key - txt
BatchNos: txt
BatchDate: dtm
OrderNo: txt
OrderDate: dtm
TyreID: fkey - txt
etc.

The table is used to track tyres going in to the factory for retreading.
Each tyre going in gets written up in a Job ticket book where each ticket is
numbered. These numbers run in the lines of '7100401-7100500'. These
numbers then get grouped into Batches in the lines of 'AA, AB, AC, etc.'.
Afterwards, when the tyres have returned from the factory and a batch is
'complete' an order number is given, but it is possible for more than one
batch to be on one Order No.
My question is if it is possible to populate the JobNo field with these 'Job
ticket Nos' without having to enter them manually, and without having to fill
the other values in the other fields.
The idea is to 'load' a new 'Job ticket book' once off. That way no
duplicates will be generated, and no numbers will be skipped/omitted. The
rest of the info will then be added afterwards.
Any ideas would be greatly appreciated,
Thanks
 
G

Graham Mandeno

Hi Jay

You can certainly use code to add a number of records to a table. For
example:

Public Function AddJobTickets(StartNum as Long, NumTickets as integer)
Dim rs as DAO.Recordset
Dim i as integer
Set rs = CurrentDb.OpenRecordset("tblJobNos", _
dbOpenDynaset, dbAppendOnly)
For i = 0 to NumTickets - 1
rs.AddNew
rs!JobNo = StartNum + i
' set other fields as required
rs.Update
Next i
End Function

You can use it like this:

Call AddJobTickets( 7100401, 100 )

I'm assuming that all the ticket numbers are numeric. But why are you using
a text field?
 

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