473,769 Members | 6,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2832
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:

txtStartSerialN o: [ ]
txtEndSerialNo: [ ]

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

dim lngCurrent as Long
dim rsSerials as DAO.Recordset
set rsSerials
=dbEngine(0)(0) .OpenRecordset( "tblSerials",db OpenTable,dbApp endOnly)
for lngCurrent=lngS tartSerial to lngEndSerial
rsSerials.AddNe w
rsSerials.Field s("SerialNo")=l ngCurrent
rsSerials.Updat e
next lngCurrent

rsSerials.Close
set rsSerials=Nothi ng

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=CIn t(txtStartNum)
intEndNum=CInt( txtEndNum)
strDateSold=txt DateSold
strSoldBy=txtSo ldBy

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*********@gma il.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
9588
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 know which account numbers are not stored in the table (not currently used) so I can use. For instance say I have the following data in table: Account Name --------- -------- 50100 Test1
5
7504
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 (faster) way: select @start = max(A) from tbl where B = 'test1' and C = 'test2' while @start <= 500000 begin insert into tbl (A, B, C) values (@start, 'test1', test2')
5
5922
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 of the class – the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initializers are provided and should...
24
4446
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 as datetime declare @end_date as datetime set @start_date as '1/1/2005' set @end_date as '1/1/2006'
4
16983
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 this error when I try to pull up my edit page to display the current database information in the form, and then edit it on click:
3
3030
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 unsatisfied with them. Here is what I have so far: declare @Sdate as datetime declare @Edate as datetime set @SDate = '07/01/2006' set @EDate = '12/31/2006'
9
3137
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 be inserted into a standard web address in the table (the filed name is link) in ddw1 Example address ---
4
4763
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 (the range) can be determined by user. The only way I know of how to do it, is creating a VBA loop with the count of the range of numbers needed and appending each instance of the loop a record to a table, and in this way creating a table with...
1
5326
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 but don't know how. Heres my xsl file so far. <?xml version="1.0" encoding="ISO-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" ...
0
9590
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9424
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10223
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10000
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.