473,387 Members | 1,517 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,387 software developers and data experts.

Translating a query from SQL Server to the Backend of Access

46
I'm trying to get the sqltext query below in a format that VB will accept, it is coded on a button in access. When I type it in, with all quotes around it along with the " & _ things, I still get errors. I'm wondering if i'm missing something because of the internal parentheses. Please help. here is the query. I've taken out all of the quotes and other connotations that didn't help.
thanks in advance.

Expand|Select|Wrap|Line Numbers
  1. Dim sqltext As String
  2.  
  3. sqltext = select * from " & _
  4. (Select type,shortname as Ward, abbrev,email,schedule.rotation, schedule.acyear, dbo.idtoname(schedule.eid) name, schedule.eid , min(startdate) start, " & _
  5.  
  6. sum(DateDiff(d, startdate, enddate) + 1) As nodays " &_
  7.  
  8. from schedule, serviceward, employee " & _
  9.  
  10. where schedule.srvcode = serviceward.srvcode
  11.  
  12. and schedule.eid = employee.eid
  13.  
  14. and hosp='U' and type=1 and schedprt=1
  15.  
  16. and acyear = " & Me.CbxAcyear" and rotation between " & Me.cbxMonth" -1 and " & Me.CbxMonth" and stfgroup=1
  17.  
  18.  
  19.  
  20. Group by type, shortname, schedule.eid, email, schedule.rotation, schedule.acyear, abbrev
  21.  
  22. ) A
  23.  
  24. where nodays >= 10
  25.  
  26. and datepart(ww,start) = datepart(ww,getdate())+1
May 2 '08 #1
2 1073
Delerna
1,134 Expert 1GB
What, exactly, are the error messages that you are getting. It will help narrow down the error if we know what error is occuring.

One immediate thing I can see is in line 3




there is a missing quote
it should be

Expand|Select|Wrap|Line Numbers
  1.    sqltext = "select * from " & _
  2.  
  3.  
May 3 '08 #2
NeoPa
32,556 Expert Mod 16PB
Teneesh, A couple of important points.
  • Always use [ CODE ] tags when posting code. This is not optional and you're a full member now so you should know this (The rules are not hidden).
  • When posting code for review, always make sure that you copy/paste the actual code tested. This has not been tested as posted as it couldn't possibly run (or even compile). Trimming the code is a good thing, but if it means we're looking at code that's never been checked to see if it does what you describe, then that extra effort is more than wasted.
  • Always compile code before posting it.
  • If there are compile errors then report the error fully and say which line (in the post - not in the module) that the error occurs on.
If you follow these simple instructions you'll find that your questions are answered more often and more correctly (and there won't be so many requests for extra information).
May 5 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ross Presser | last post by:
The purpose, as you can probably guess, is to produce a set of sample documents from a large document run. The data row has a CLUB column and an IFC column; I want a set of samples that contains...
1
by: David | last post by:
Hi everyone. I have read every page that Google returns on this topic, but can't find anything that resolves my problem. Basically, I have an Access Database that does a number of different...
29
by: Mark B | last post by:
We have an Access app (quite big) at www.orbisoft.com/download. We have had requests by potential users to have it converted to an SQL version for them since there corporate policy excludes them...
3
by: s_wadhwa | last post by:
Hi, I'm trying to convert MS Access 97 .mdb application to Access 2003 .adp application with SQL Server as Backend. I'm having trouble converting Access Query into SQL Query. The Query is...
3
Craash
by: Craash | last post by:
I understand this is an access forum so I apologize if this is inappropriate. I have an excel spreadsheet that I have created a query using a DSN to access a sql database. My question; is there a...
1
by: timn | last post by:
Translating Access SQL queries into SQL subqueries. -------------------------------------------------------------------------------- I have a query in Access that uses a subquery, I would like...
10
by: gary0gilbert | last post by:
An unusual spin to this recurring disk or network error in a Terminal Server environment. Access 2000, Terminal Server 2000, file server is windows 2000. All users have a separate copy of the...
5
by: bobh | last post by:
Hi All, Is there a difference in preformance between the two; TblNme has 36 fields across a record a query that selects all fields and the report only uses 75% of the fields, ie; Select...
1
by: =?Utf-8?B?VmlqYXkgQ2hpa3Rl?= | last post by:
Hi Experts, With Session Affinity and Web Server Farm on ISA Server 2006 accessing 2 backend IIS servers, I’m getting error “Validation of ViewState MAC failed. If this application is hosted...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...

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.