473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Autocreate records and print them

Lol
My apologies if this has been asked a thousand times before:
I have (to start with) a simple database with a single table and a
single report.
The purpose of the database is to allow gift vouchers to be printed,
each with a unique serial number. To achieve this I have set up a the
table with an autonumber field (my unique serial number) and a report
that looks like a gift voucher including the serial number. Now comes
the tricky bit:
I would like a set up a form whereby I can select a number of vouchers
to print. On entering the number (say 20) the system should create 20
records in my table, which will have the next 20 sequential serial
numbers, and print these last 20 records as vouchers through the
report.

To do this I think I need to find a way to auto create the correct
number of records and then print the report against a select query
which contains the these last 20 records.

Anyone have any ideas?
Nov 13 '05 #1
1 1686
This example shows how to add records to a table named "MyTable", with these
fields:
VoucherID Number field (not AutoNumber)
ClientID field to tell who bought the voucher
PurchaseDate Date/Time when the voucher was bought
Function MakeVoucher(HowMany As Long)
Dim rs As DAO.Recordset
Dim lng As Long
Dim lngLastNumber As Long

Set rs = DBEngine(0)(0).OpenRecordset("MyTable", dbOpenDynaset)
If rs.RecordCount > 0 Then
rs.MoveLast
lngLastNumber = rs!VoucherID
End If
For lng = 1 To HowMany
rs.AddNew
rs!VoucherID = lngLastNumber + lng
rs!ClientID = Forms!MyForm!MyClient
rs!PurchaseDate = Date
rs.Update
Next
rs.Close
MsgBox "New vouchers numbered from " & lngLastNumber + 1
Set rs = Nothing
End Function
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Lol" <p0*******@hotmail.com> wrote in message
news:79**************************@posting.google.c om...
My apologies if this has been asked a thousand times before:
I have (to start with) a simple database with a single table and a
single report.
The purpose of the database is to allow gift vouchers to be printed,
each with a unique serial number. To achieve this I have set up a the
table with an autonumber field (my unique serial number) and a report
that looks like a gift voucher including the serial number. Now comes
the tricky bit:
I would like a set up a form whereby I can select a number of vouchers
to print. On entering the number (say 20) the system should create 20
records in my table, which will have the next 20 sequential serial
numbers, and print these last 20 records as vouchers through the
report.

To do this I think I need to find a way to auto create the correct
number of records and then print the report against a select query
which contains the these last 20 records.

Anyone have any ideas?

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Chris Lasher | last post by:
Hello, I have a rather large (100+ MB) FASTA file from which I need to access records in a random order. The FASTA format is a standard format for storing molecular biological sequences. Each...
1
by: Ian Davies | last post by:
Hello In a php file I have a drop down list with index numbers in whos default value is feed into an sql query that filters records from my database and displays them in an html table. Trouble...
1
by: MLH | last post by:
I have a challenge... In a table I call tblStuff4Letters with 3 fields: , and . I have a report called rptOutboundCorrespondence that feeds off this table. Sorting & grouping is turned on in...
3
by: TM | last post by:
Is there any way that I can take the records from a datagrid and paste them into an Excel sheet, then print preview or print the sheet ? Is there any way I can sort the sheet before I print it ?...
7
by: itm | last post by:
I have a mail out to send to a group of owners with multiple accounts. I want to limit the number of accounts that print on the first page to 20. I want remaining accounts to print on a second...
6
by: Christo | last post by:
I have this script for showing news on a page, but i want it to only show the last 10 records, as in the 10 records that were added to the database last. the script shows the entries in descending...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
4
by: ske | last post by:
Hi I've inherited an Access database where there is a form setup which prints out a Job Sheet. This works fine with one record. However I need to set it to loop through several records and print...
2
by: asdf | last post by:
So I'm writing a script which will create several instances of User() class. I want each instance to be named after the login name of a user. I don't know beforehand how many users the script will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.