473,396 Members | 2,050 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,396 software developers and data experts.

INSERT INTO help please...

Query1:
tDate TrapNo Species AmtColl
1/1/2000 E1 TAE 100
1/1/2000 E1 COL 150
1/1/2000 E1 TIT 205
I need to Insert these rows into another table with this setup:
tDate TrapNo TAE COL TIT
1/1/2000 E1 100 150 205

Any suggestions are greatly appreciated!

Take Care,

j

Nov 8 '06 #1
3 1068
jamesfreddyc wrote:
Query1:
tDate TrapNo Species AmtColl
1/1/2000 E1 TAE 100
1/1/2000 E1 COL 150
1/1/2000 E1 TIT 205
I need to Insert these rows into another table with this setup:
tDate TrapNo TAE COL TIT
1/1/2000 E1 100 150 205

Any suggestions are greatly appreciated!

Take Care,

j
Go to the queries tab, click new, Crosstab (or Pivot) and play around
with that.

You might need to create a routine/function to insert the results since
grouped queries usually don't work in append queries.

Nov 8 '06 #2
Create your new table and run
something of this nature (Air code).

Sub Unstack()
Dim db As Database
Dim RSOld As Recordset
Dim RSNew As Recordset
Dim strTrapMark As String
Dim strtDateMark as Date
Set db = CurrentDb
Set RSOld = db.OpenRecordset("qry1", dbOpenSnapshot)
Set RSNew = db.OpenRecordset("tblNew", dbOpenDynaset)
RSOld.MoveFirst
Do While Not RSOld.EOF
strTrapMark = RSOld!TrapNo
strtDateMark = RSOld!tDate
RSNew.AddNew
RSNew!Tdate = RSOld!TDate
RSNEW!TrapNo= RSOLd!Trapno
Do While RSOld!Tdate = strDateMark AND _
RSOld!TrapNo = strTrapMark And Not RSOld.EOF
If RSOld!Species = "TAE" then
RSNew!TAE = RSOld!AmtColl
ElseIf RSOld!Species = "COL" Then
RSNew!COL = RSOld!AmtColl
Else
RSNew!Species = RSOld!AmtColl
End If
RSNew.Update
RSOld.MoveNext
Loop
Loop

Kevin C

"jamesfreddyc" <ja**********@comcast.netwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
Query1:
tDate TrapNo Species AmtColl
1/1/2000 E1 TAE 100
1/1/2000 E1 COL 150
1/1/2000 E1 TIT 205
I need to Insert these rows into another table with this setup:
tDate TrapNo TAE COL TIT
1/1/2000 E1 100 150 205

Any suggestions are greatly appreciated!

Take Care,

j

Nov 14 '06 #3

Try sql along the following lines:

select a.tDate, a.TrapNo, a.amtcoll as TAE, b.amtcoll as COL, cmtcoll
as TIT
from myTable a, myTable b, myTable c
where a.tDate = b.tDate
and a.tDate = c.TDate
and a.TrapNo = b.TrapNo
and a.TrapNo = c.TrapNo
and a.Species = "TAE"
and b.Species = "COL"
and c.Species = "TIT"

Nov 14 '06 #4

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

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
1
by: newbie_mw | last post by:
Seems my post was buried in more cries for help :-) I will try again. It's probably a very novice question so please take a look! Thanks!...
8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
5
by: Rob | last post by:
I'm trying to use the set<my_class>::insert( my_class const & ) method, but have run into some problems. It seems like I'm seeing it insert an object when a similar object is already in the set. ...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
0
BenRatcliffe
by: BenRatcliffe | last post by:
Hi there, I was wondering if anyone could help me. I have a comlpex database with a number of forms that have data entered on them and then saved into the correct table etc. In this instance I am...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
4
by: =?Utf-8?B?RXJpYyBGYWxza2Vu?= | last post by:
We’re storing our main entity in an insert only table which stores the history of past revisions, but we’re facing problems with storing this history as LINQ will only update the entity, and...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
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,...

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.