473,394 Members | 1,740 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,394 software developers and data experts.

Adding a range of numbers from a form to a table

What I would like to do is input a range of serial numbers in a form
and have that range populate in the table without me having to put them
in one at a time manually. The numbers do not exist yet, either. I'm
not sure how else to explain it.

The tables I use have the following Fields:
Table 1
(PK) Serial Number
Date Sold
Sold By

Table 2
(PK) Serial number
Date Redeemed
Redeemed By

This is for a gift certificate database. Sometimes we sell more than
one gift certificate at a time by the same seller on the same date.
Sometimes we sell up to 1000 to 1500 gift certificates a day so you can
see that inputting the certificate number can get tedious at times. I
have 2 different forms aswell

Here are the following fields for both forms:

Form 1:
From Number To Number
Date Sold
Sold By

Form 2:From Number

To Number
Date Redeemed
Redeemed By

I also want to be able to detect if a serial number in the redeemed
database, doesn't exist in the sold database. As well as catch
duplicate serial numbers sold and redeemed. Does this make any sense
and is it do-able. Thanks for your help
~tai

Dec 28 '05 #1
3 2802
I'm working on a similar problem. The way I would handle it is
something like this:

CREATE TABLE GiftCertificate(
SerialNumber varchar2(25) PRIMARY KEY,
DateSold date,
SoldBy VARCHAR2(50),
DateRedeemed Date,
RedeemedBy VARCHAR2(50)
);

If you do it this way, you can't add duplicate Serial numbers, because
the PK takes care of that for you.

Okay, adding a series of SerialNumbers...

You'd have an *unbound* form (doesn't write directly to the table) with
a few fields on it.
Something like:

txtStartSerialNo: [ ]
txtEndSerialNo: [ ]

then you could have code along the lines of
Sub cmdCreateCertificates(byval lngStartSerial as Long, byval
lngEndSerial As Long)

dim lngCurrent as Long
dim rsSerials as DAO.Recordset
set rsSerials
=dbEngine(0)(0).OpenRecordset("tblSerials",dbOpenT able,dbAppendOnly)
for lngCurrent=lngStartSerial to lngEndSerial
rsSerials.AddNew
rsSerials.Fields("SerialNo")=lngCurrent
rsSerials.Update
next lngCurrent

rsSerials.Close
set rsSerials=Nothing

Dec 28 '05 #2
Are your tables in two different databases or did your words just get
mixed up? It looks to me like Table1 is the 'sold' table and Table2 is
the 'redeemed' table, both in the same database.

The VBA code for inserting a range of records into your 'sold' table is
such:

Dim intStartNum as Integer
Dim intEndNum as Integer
Dim strDateSold as String
Dim strSoldBy as String
intStartNum=CInt(txtStartNum)
intEndNum=CInt(txtEndNum)
strDateSold=txtDateSold
strSoldBy=txtSoldBy

Dim x as Integer
For x=intStartNum To intEndNum
DoCmd.RunSQL "INSERT INTO tblSold (SerialNbr, DateSold, SoldBy) VALUES
(" & x & ", '" & strDateSold & "', '" & strSoldBy & "');"
Next x

Untested.

Do the same thing for your 'redeemed' table.
Checking to see if a serial nbr is in both tables can be done using a
query and a join between thet two tables on the serial nbr field.

This code has no error-checking or input validation: those are your
responsibility to furnish.

Dec 28 '05 #3
On 28 Dec 2005 10:55:08 -0800, ta*********@gmail.com wrote:
What I would like to do is input a range of serial numbers in a form
and have that range populate in the table without me having to put them
in one at a time manually. The numbers do not exist yet, either. I'm
not sure how else to explain it.

The tables I use have the following Fields:
Table 1
(PK) Serial Number
Date Sold
Sold By

Table 2
(PK) Serial number
Date Redeemed
Redeemed By

This is for a gift certificate database. Sometimes we sell more than
one gift certificate at a time by the same seller on the same date.
Sometimes we sell up to 1000 to 1500 gift certificates a day so you can
see that inputting the certificate number can get tedious at times. I
have 2 different forms aswell

Here are the following fields for both forms:

Form 1:
From Number

To Number
Date Sold
Sold By

Form 2:
From Number

To Number
Date Redeemed
Redeemed By

I also want to be able to detect if a serial number in the redeemed
database, doesn't exist in the sold database. As well as catch
duplicate serial numbers sold and redeemed. Does this make any sense
and is it do-able. Thanks for your help
~tai


Firstly, you don't need separate tables as there is a one to one
relationship on the primary key in both tables ie just add fields Date
Redeemed and Redeemed By to Table 1

In your Form 1, I'd have the input as From Number and Number Sold. Use
a Do Loop to append the Sold certificates. Similarly for Form 2, but
use an update query to automate the changes.

P

Dec 29 '05 #4

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

Similar topics

2
by: Jason | last post by:
What I am trying to do is get all of the records in a table that are out of sequence so I know which account numbers I can reuse. I have a range of account numbers from 50100 to 70100. I need to...
5
by: ratu | last post by:
I'd like to use a stored procedure to insert large amounts of records into a table. My field A should be filled with a given range of numbers. I do the following ... but I'm sure there is a better...
5
by: surrealtrauma | last post by:
the requirement is : Create a class called Rational (rational.h) for performing arithmetic with fractions. Write a program to test your class. Use Integer variables to represent the private data...
24
by: PromisedOyster | last post by:
Is there a way that I can get a resultset that contains unique dates in a given date range without the need to have a temporary table and a cursor? perhaps something like: declare @start_date...
4
by: Todd Perkins | last post by:
Hello all, surprisingly enough, this is my first newsgroup post, I usually rely on google. So I hope I have enough info contained. Thank you in advance for any help! Problem: I am getting...
3
by: rugger81 | last post by:
I am currently working in the sql server 2000 environment and I want to write a function to pull all dates within a given date range. I have created several diferent ways to do this but I am...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
4
by: Michael R | last post by:
Hi. I'm currently dealing with the following: I need a drop box that will have in it a certain range of accending consuquential numbers for ex: 1, 2, 3, 4, 5, 6, 7. The min and the max number...
1
by: cleary1981 | last post by:
Hi, I am trying to add page numbers to my document in xsl fo. I can get the page numbers to work but I need them to show at the bottom of each page. I know you can define an area as region-after...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.