Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 22nd, 2004, 12:45 PM
shawn shawn is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 24 shawn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with Access to SQL

I have a program written in Access 97. I need to transfer it to SQL tables. I have that part done.

I have a query now, that I need to translate, so to speak. If anyone can help me out, I'd greatly appreciate it.

Here's the Access database access code.
SELECT DISTINCTROW Table1.PartNumber,
Table1.Description,
Table1.RevisionLevel,
Table1.Status,
Table1.MinimumQty,
Table1.LotSize,
Table1.PartNumberBase,
Table2.CustomerPartNumber,
DLookUp("[fcompany]","slcdpm","[fcustno] = '" & [Table2].[CustomerNumber] & "'") AS Customer,
[Forms]![frmToPrintSearchRequest]![txtCustomerPartNumber] AS frmCPN,
[Forms]![frmToPrintSearchRequest]![txtPartNumber] AS frmPN
FROM Table1
LEFT JOIN Table2
ON Table1.PartNumber = Table2.PartNumber
WHERE (((Table1.PartNumberBase) LIKE [Forms]![frmToPrintSearchRequest]![txtPartNumber] & "*")
AND (([Forms]![frmToPrintSearchRequest]![txtCustomerPartNumber]) Is Null)
AND (([Forms]![frmToPrintSearchRequest]![txtPartNumber]) Is Not Null))
OR (((Table1.PartNumberBase) Like [Forms]![frmToPrintSearchRequest]![txtPartNumber] & "*")
AND ((Table2.CustomerPartNumber) Like "*" & [Forms]![frmToPrintSearchRequest]![txtCustomerPartNumber] & "*")
AND (([Forms]![frmToPrintSearchRequest]![txtCustomerPartNumber]) Is Not Null)
AND (([Forms]![frmToPrintSearchRequest]![txtPartNumber]) Is Not Null))
OR (((Table2.CustomerPartNumber) Like "*" & [Forms]![frmToPrintSearchRequest]![txtCustomerPartNumber] & "*")
AND (([Forms]![frmToPrintSearchRequest]![txtCustomerPartNumber]) Is Not Null)
AND (([Forms]![frmToPrintSearchRequest]![txtPartNumber]) Is Null))
ORDER BY Table1.PartNumber;


The DLookups are looking up a table on a different database...not that that matters, but I thought I'd just throw that out there.
And I'm failry certain that all the conditionals in the WHERE do not need to be there...I think it can be done with just one condition, using LIKE.

I got confused mainly around the DLookup, because it is essentially nested queries. And if it makes any difference, I am doing this in Cold Fusion.

Thanks a ton.

Shawn

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Help with Access to SQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT