Adding records to a table (1 Viewer)

plawrence85

New member
Local time
Today, 05:55
Joined
Sep 17, 2008
Messages
3
I am writing a relatively simple database to print serial number tags and maintain a record of the data.
I have a table for the serial numbers and all related information.
I have a form where the end user enters some basic information about the tags including the quantity for the print run.
My difficulty occurs in taking this user data and adding the new records to the serial number table.
Say a user enters a quantity of six tags to be printed.

How can I generate the next six serial numbers and add those to the existing table?

Thanks for your thoughts.
 

Rabbie

Super Moderator
Local time
Today, 10:55
Joined
Jul 10, 2007
Messages
5,906
Use the DMAX function to find the latest serial number in use and then allocate the next six.
 

plawrence85

New member
Local time
Today, 05:55
Joined
Sep 17, 2008
Messages
3
Thanks Rabbie.

DMAX will let me increment the next six serial numbers but how do those six new records get added to the table?

On the form, the user enters the data (Work Order #, Capacity & Quantity).
Once entered they hit ‘SEND TO PRINTER’.
This will trigger a macro that looks in the serial number table, finds the last number, generates the next sequence of numbers, adds those numbers to the table with the other data and then triggers the print macro.

It’s the whole Adding those numbers to the table automatically that has me at a loss.
 

Rabbie

Super Moderator
Local time
Today, 10:55
Joined
Jul 10, 2007
Messages
5,906
Just use some VBA to add the records.
 

plawrence85

New member
Local time
Today, 05:55
Joined
Sep 17, 2008
Messages
3
I’ve been trying to write the VBA code to add the records to the Axle_Data table. XX is the number of new tags to be printed. SN is the last serial number in the table.
I can open the table but I cannot figure out how to actually add the next XX serial numbers to the table. This is the module as it sits now. I have a basic For..Next loop that increments the serial numbers. What command will add that number to the table?

Thanks for any assistance.


Sub Count()

Dim xx As Integer
Dim sn As Long

xx = DLookup("Quantity", "Print_request_table")
sn = DLookup("SerialN", "Axle_Data")

DoCmd.OpenTable "Axle_Data", , acAdd

For ct = 1 To xx

an = sn + ct

- Mystery code here -

Next

End Sub
 

Users who are viewing this thread

Top Bottom