|
-
Apr 8th, 2003, 06:30 PM
#1
Thread Starter
Lively Member
Re:SQL syntax for access
is it valid syntax to refer to a field in a db ilke this:
adoRecordset!Orders.OrderID ?
i have to do this because my SQL statement needs to distinguish this field form anothre field with the same name in an other table?
-
Apr 8th, 2003, 06:51 PM
#2
Need-a-life Member
I cannot tell but you can always do something like this:
SELECT Orders.OrderID As O_OrderId, Items.OrderID As I_OrderId FROM Orders, Items WHERE SellID = 1
And then you can use it like:
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 8th, 2003, 07:52 PM
#3
Thread Starter
Lively Member
that did not work
here is my sql statement that is generated from access
SELECT Orders.OrderID, Orders.CustomerID, Orders.StartDate, Orders.ExpiryDate, Magazines.Price, Orders.Status
FROM Magazines INNER JOIN Orders ON Magazines.MagazineID = Orders.MagazineID
Debug.Print adoRecordset!OrderID, adoRecordset!CustomerID, adoRecordset!StartDate, adoRecordset!ExpriyDate,
is there an error in here?
-
Apr 8th, 2003, 07:57 PM
#4
Need-a-life Member
Yes!! The error is that you did not do what I told you to.
VB Code:
"SELECT Orders.OrderID [b]AS O_OrderID[/b], " & _
"Orders.CustomerID AS [b]O_CustomerID[/b], " & _
"Orders.StartDate [b]AS O_StartDate[/b], Orders.ExpiryDate [b]AS O_ExpriyDate[/b], " & _
"Magazines.Price, Orders.Status " & _
"FROM Magazines INNER JOIN Orders ON Magazines.MagazineID = Orders.MagazineID"
Debug.Print adoRecordset!O_OrderID, adoRecordset!O_CustomerID, _
adoRecordset!O_StartDate, adoRecordset!O_ExpriyDate
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 8th, 2003, 08:05 PM
#5
Thread Starter
Lively Member
I DID DO THAT ! I WAS LISTENING! but it aint working ! the error message that i am getting is :
item cannot be found in the collectin corresponding to the requested name or ordinal
-
Apr 8th, 2003, 08:06 PM
#6
As far as I can tell
SELECT Orders.OrderID, Orders.CustomerID, Orders.StartDate, Orders.ExpiryDate, Magazines.Price, Orders.Status
FROM Magazines INNER JOIN Orders ON Magazines.MagazineID = Orders.MagazineID
is a perfectly valid SQL statement.
You're not selecting multiple fields with the same field name.
Use McBrains suggestion if you plan to extract fields from multiple tables where the names of the fields are the same.
-
Apr 8th, 2003, 08:07 PM
#7
Need-a-life Member
Try this:
VB Code:
"SELECT Orders.OrderID AS O_OrderID, " & _
"Orders.CustomerID AS O_CustomerID, " & _
"Orders.StartDate AS O_StartDate, Orders.ExpiryDate AS O_ExpriyDate, " & _
"Magazines.Price, Orders.Status " & _
"FROM Magazines INNER JOIN Orders ON Magazines.MagazineID = Orders.MagazineID"
Debug.Print adoRecordset!O_OrderID
Debug.Print adoRecordset!O_CustomerID,
Debug.Print adoRecordset!O_StartDate
Debug.Print adoRecordset!O_ExpriyDate
and tell me which line do you get the error at.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 8th, 2003, 08:16 PM
#8
Thread Starter
Lively Member
sorry yall! i forgot to change one of the field names to one of the alisas ! my bad !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|