473,786 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with copying data from one table to another

daD
I'm trying to write a small database that tracks people coming and
going from a small campground. I need to have the current guests in
the "current" table" and then have the ability to check them out to
the "archive" table when they leave, by pushing the "check-out"
button. I see the steps as follows:

1. When the check-out button is pressed, the computer should
automatically add the current date into the "date checked-out" field.

The computer should then ask "are you sure?"

2. If the answer is "yes", then the computer should automatically
move the whole record from the "current" table to the "archive"
table.

If the answer is "no", then the computer should ease the date written
into the "date checked-out" field".

I am using Access 2003. I realize this is probably a macro, but I
guess it's beyond me. I need some real talent to help me. Any help
is greatly appreciated.
James
Sep 3 '06 #1
8 3360
Why not just leave all the data in the same table and include a
CheckOutDate field? then your query would be something like

'--- untested code...

private sub cmdArchiveData( )

dim intReply as integer '--- somewhere to stuff the response from the
MsgBox function.

intReply=MsgBox ("Are you sure you want to archive this
record?",vbYesN o,"You're about to archive this record...")

if intReply=vbYes then
'---update only the current record on the form...
CurrentDB.Execu te "UPDATE tblReservation SET CheckOutDate = Now
WHERE tblReservation. ReservationID=" &
Forms![MyForm]![txtReservationI D]
end if

end sub

Sep 3 '06 #2
Moving a record to another table consists of executing an Append query (to
add it to the other table), followed by a Delete query. The code you need to
achieve this is explained in this article:
Archive: Move records to another table
at:
http://allenbrowne.com/ser-37.html

However, it seems to me that this is not a relational design. Presumably you
have clients (who could come back some day), and lots (sections of the
camping), and you assign a lot to a client for a brief period. This suggests
3 tables:
Client (one record for each hirer) with fields:
ClientID AutoNumber
Surname Text family name
FirstName Text Christian name of the responsible person
Address Text person's home address
...

Lot (one record for each lot in your camping ground). Fields:
LotID Number
...

Hiring (one record for each time a client rents a lot.) Fields:
LotID Number which lot was hired
ClientID Number which client hired it
FirstNight Date/Time first night of this booking
FinalNight Date/Time last night of booking

Advantages of this approach:
- Client only has to be entered once, even if they have multiple bookings.
- Easy to query usage (history of a lot, what's available when.)
- No need to move records into another table.

--
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.

"daD" <JA********@COX .NETwrote in message
news:ab******** *************** *********@4ax.c om...
I'm trying to write a small database that tracks people coming and
going from a small campground. I need to have the current guests in
the "current" table" and then have the ability to check them out to
the "archive" table when they leave, by pushing the "check-out"
button. I see the steps as follows:

1. When the check-out button is pressed, the computer should
automatically add the current date into the "date checked-out" field.

The computer should then ask "are you sure?"

2. If the answer is "yes", then the computer should automatically
move the whole record from the "current" table to the "archive"
table.

If the answer is "no", then the computer should ease the date written
into the "date checked-out" field".

I am using Access 2003. I realize this is probably a macro, but I
guess it's beyond me. I need some real talent to help me. Any help
is greatly appreciated.
James

Sep 3 '06 #3
daD
Sorry, should have mentioned that the former owner already had a
database built in access 2000 that has thousands of former customers.
I don't like this database, which is why i am trying to craete a new
one. This customer base is importnat to me for marketing efforts,
etc. I want to import that past data into my "archive" table and
query from there to support a direct marketing campaign designed to
lure former guests back for another stay. However, we're talking
about close to 20,000 people, so I don't want them cluttering up the
"curent" table, which only has a max numner 0f 812 (the number of
camping spots) That is why I need to copy from table to table.
Thanks so much for your help, Mr. Browne and everyone else who
answered.

James
On Sun, 3 Sep 2006 12:03:17 +0800, "Allen Browne"
<Al*********@Se eSig.Invalidwro te:
>Moving a record to another table consists of executing an Append query (to
add it to the other table), followed by a Delete query. The code you need to
achieve this is explained in this article:
Archive: Move records to another table
at:
http://allenbrowne.com/ser-37.html

However, it seems to me that this is not a relational design. Presumably you
have clients (who could come back some day), and lots (sections of the
camping), and you assign a lot to a client for a brief period. This suggests
3 tables:
Client (one record for each hirer) with fields:
ClientID AutoNumber
Surname Text family name
FirstName Text Christian name of the responsible person
Address Text person's home address
...

Lot (one record for each lot in your camping ground). Fields:
LotID Number
...

Hiring (one record for each time a client rents a lot.) Fields:
LotID Number which lot was hired
ClientID Number which client hired it
FirstNight Date/Time first night of this booking
FinalNight Date/Time last night of booking

Advantages of this approach:
- Client only has to be entered once, even if they have multiple bookings.
- Easy to query usage (history of a lot, what's available when.)
- No need to move records into another table.
Sep 3 '06 #4
If you design your database right and load only the records you need,
then the 20K records is largely immaterial. As a general rule, don't
base forms directly off tables. Especially if you're sharing the
backend across a network. The peformance will be horrible. If I were
you, I would create a new database and normalize first and then deal
with archived data. you could move it to an "archive" table, but then
you could just as easily base your form on a query...

SELECT <field>, <field>...
FROM <mytable>
WHERE MyTable.Archive =False

or some such thing that just essentially hides the archived data.
Otherwise, you have to muck with union queries, and that's not fun.

Sep 5 '06 #5
daD
OK, I think I am on the right track. All the forms are planned to be
based on queries off the 'current" table, except the 'past guests"
form, which is based off a query of the "archive" table, so I can see
who has stayed with us in the past.

i also have a need to know how many people are in the campground each
day. I would like the databse to run a query every day at maybe 8:00
(it should be the same time every day and should be automated) in the
morning and count the number of camping spaces that were occupied and
then store that number somewhere for later use. At the end of the
month I could run a report that lists that number for each day like:

1 800
2 799
3 811

Something simple like that. Is using a temporary table the way to go?
Something I could erase every month and start the whole thing over
again?

I have also been toying with the idea of using a web page as the
front-end. I think that there is so much more frredom in the design
with a web page and a lot of resources for graphics, etc.... Has
anyone ever done anything like that, or do you know of any utilities
that would make it easier to really make it look nice? Access seems a
littel short in that area. i guess I could design the background for
the forms in Frontpage or Photoshop and then put the fields in the
forground. Basically, I want my users accessing the database through
a browser, even though the whole thing (front-end and back-end) would
stay on my network. Tthanks agian to all you great people for sharing
your knowledge!

On 4 Sep 2006 21:09:41 -0700, pi********@hotm ail.com wrote:
>If you design your database right and load only the records you need,
then the 20K records is largely immaterial. As a general rule, don't
base forms directly off tables. Especially if you're sharing the
backend across a network. The peformance will be horrible. If I were
you, I would create a new database and normalize first and then deal
with archived data. you could move it to an "archive" table, but then
you could just as easily base your form on a query...

SELECT <field>, <field>...
FROM <mytable>
WHERE MyTable.Archive =False

or some such thing that just essentially hides the archived data.
Otherwise, you have to muck with union queries, and that's not fun.
Sep 6 '06 #6

daD wrote:
OK, I think I am on the right track. All the forms are planned to be
based on queries off the 'current" table, except the 'past guests"
form, which is based off a query of the "archive" table, so I can see
who has stayed with us in the past.

i also have a need to know how many people are in the campground each
day. I would like the databse to run a query every day at maybe 8:00
(it should be the same time every day and should be automated) in the
morning and count the number of camping spaces that were occupied and
then store that number somewhere for later use.
On the right track? if you're thinking of putting all this calculated
junk in a table, I'd beg to differ. If you base your forms off queries
and your tables are properly indexed, and you only pull the data you
need from each table, then who cares how many records are in your
tables? Why not just query the live data? The query is a little
weird, but once you have it, you're there. I think storing all this
junk is a waste of space and time, unless you really need it for
querying later and you have so many records that querying the whole
dataset is unwieldy.

Sep 6 '06 #7
daD
OK, OK. Maybe not on the right track? I just need to know how many
camping sites were occupied on a given day and I thought I should
check that number at the same time every day to establish a standard.
This helps me establiush a trend of high occupancy times of the year
and low occupancy times of the year. Maybe I can offer incentives
during the slow months to lure customers in. How else would I be able
to get this info? You said somnething about indexes? I want to do it
the easiest way possible obviously, but I really want to use the past
records I inherited and that is over 31,00 records. Thanks again for
helping out.

.On 5 Sep 2006 17:22:56 -0700, pi********@hotm ail.com wrote:
>
daD wrote:
>OK, I think I am on the right track. All the forms are planned to be
based on queries off the 'current" table, except the 'past guests"
form, which is based off a query of the "archive" table, so I can see
who has stayed with us in the past.

i also have a need to know how many people are in the campground each
day. I would like the databse to run a query every day at maybe 8:00
(it should be the same time every day and should be automated) in the
morning and count the number of camping spaces that were occupied and
then store that number somewhere for later use.

On the right track? if you're thinking of putting all this calculated
junk in a table, I'd beg to differ. If you base your forms off queries
and your tables are properly indexed, and you only pull the data you
need from each table, then who cares how many records are in your
tables? Why not just query the live data? The query is a little
weird, but once you have it, you're there. I think storing all this
junk is a waste of space and time, unless you really need it for
querying later and you have so many records that querying the whole
dataset is unwieldy.
Sep 6 '06 #8
daD <JA********@COX .NETwrote in
news:jg******** *************** *********@4ax.c om:
OK, OK. Maybe not on the right track? I just need to know how
many camping sites were occupied on a given day and I thought
I should check that number at the same time every day to
establish a standard. This helps me establiush a trend of high
occupancy times of the year and low occupancy times of the
year. Maybe I can offer incentives during the slow months to
lure customers in. How else would I be able to get this info?
You said somnething about indexes? I want to do it the
easiest way possible obviously, but I really want to use the
past records I inherited and that is over 31,00 records.
Thanks again for helping out.

.On 5 Sep 2006 17:22:56 -0700, pi********@hotm ail.com wrote:
>>
daD wrote:
>>OK, I think I am on the right track. All the forms are
planned to be based on queries off the 'current" table,
except the 'past guests" form, which is based off a query of
the "archive" table, so I can see who has stayed with us in
the past.

i also have a need to know how many people are in the
campground each day. I would like the databse to run a query
every day at maybe 8:00 (it should be the same time every
day and should be automated) in the morning and count the
number of camping spaces that were occupied and then store
that number somewhere for later use.

On the right track? if you're thinking of putting all this
calculated junk in a table, I'd beg to differ. If you base
your forms off queries and your tables are properly indexed,
and you only pull the data you need from each table, then who
cares how many records are in your tables? Why not just query
the live data? The query is a little weird, but once you have
it, you're there. I think storing all this junk is a waste of
space and time, unless you really need it for querying later
and you have so many records that querying the whole dataset
is unwieldy.
First of all, you should NOT have two tables, current and past
guests. You have one table "guests" and a field that indicates
the "past status", the date and time the guest left. It would
also help to store the date and time the guest arrived, and the
location number...

Then it becomes very easy to query the data for any particular
date and time for the info you want...
SELECT count(location) as Occupancy from Gusest where [enter a
date and time for count BETWEEN dtArrival and dtDeparture.

No need for automation, storing results, etc.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Sep 6 '06 #9

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

Similar topics

1
32354
by: Caroline | last post by:
I need to update a table by copying a column from another table (having the same structure, but on another database), from the record having the same primary key. 1 - What is the correct query? 2 - I tried copying them record by record, but the datatype is ntext, (it displays <long
2
1724
by: Sebastian | last post by:
The following query needs about 2 minutes to complete (finding dupes) on a table of about 10000 addresses. Does anyone have an idea on how to speed this up ? Thanks in advance !!! Sebastian
3
3424
by: radioman | last post by:
Hi all, I would appreciate some help please. I just need pointing in the right direction as I am at a loss. Basically I have a form (frmAddMaster) which displays two subforms "Master Stock subform" and "Client Stock Template subform". Each subform contains the following fields "Product ID,Product Description and Size". What I am trying to do is to select rows from the "Master Stock subform" and copy them to "Client Stock Template...
5
3514
by: Lyn | last post by:
I am trying to copy selected fields from one table to another, by reading the source table record into a recordset (ADO) and then copying the relevant fields to an SQL statement "INSERT INTO...". The numeric and text fields copy without a problem, but it all falls in a heap when I try to copy a picture object field (data type OLE Object in both tables). I seem to be missing something ??? Reduced to its simplest form, this is the code...
48
3880
by: phillip.s.powell | last post by:
MySQL 3.23.58 - 4.0.17 (yep, several database server instances, don't ask) I have database Spring with table Students I have database Summer with table Students I am tasked to produce a query of all students in both tables with no duplicates. No clue whatsoever.
0
1566
by: berwiki | last post by:
I am trying to copy a table to another SQL 2000 Database, but I continually get errors. When I right-click, choose All-Tasks, Export-Data and go through the DTS settings, I get an 'Unspecified Error' on row 107 (which, looking at all visible data, there appears to be no difference than the 100 rows before it). Failed: Copying to a different database. Failed: Copying to the Same database with a different table name.
5
17520
by: ozzii | last post by:
Hi I am using the following code to copy data from one database table into another database table: SELECT * INTO Products From exportdb.mdb.exporttable However the query simply deletes everything in the Products table before copying the content of the exporttable. what is the syntax to run a similar query so that data is simply appended to the products table instead of deleting the entire contents before copying the exporttable?
1
1874
by: corsibu | last post by:
hello , i just wanted to ask if there's anyone who could help me do the following thing : i have an empty temporary table, this table will have a row filled with data grabbed by a querry at this point this point another query filters this data (it was the only way to do this as i know) and inserts it into an empty table called MOVIMENTI. until here all works just fine. after i finished this part i grab the data from MOVIMENTI and other 2...
5
1897
by: mark_aok | last post by:
Hi all, I have a situation where I have a split database. At the back end, I need to - create a new table (I will call it newTable) with the exact fields, and relationships as another table (let's call it oldTable, and I need to copy everything EXCEPT the data). - Then I need to delete oldTable, and rename newTable 'oldTable'
0
9647
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
10357
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...
0
9959
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
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
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();...
1
4063
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
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.