Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

SQL statment and VB6 issues - Help please


  • Please log in to reply

#1
Wyattda

Wyattda

    New Member

  • Member
  • Pip
  • 3 posts
I have created a query in MS access that gives me a percentage of 2 "Count" values from other queries. I'm using an ADO control with ODBC to connect to my DB. Well, when I try to point the record source to the query I've made it gives me the following error:

[Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.

Here is my SQL query:

SELECT [qry1]![calls]/[qry2]![CountOfCallID] AS count2
FROM qry1, qry2;

Here is my Access query:

count2: [qry1]![calls]/[qry2]![CountOfCallID]


Qry1 is as follows:

SELECT Count(Calls.CallID) AS calls
FROM Calls
WHERE (((Calls.TimeTaken)=[Time]) AND ((Calls.Date)=Date()) AND ((Calls.DateReceived)=[calls]![datetaken]));

Calls is the only table I’m working with and TimeTaken is a column and so on..

Qry2 is as follows:

SELECT Count(Calls.CallID) AS CountOfCallID
FROM Calls
GROUP BY Calls.Date
HAVING (((Calls.Date)=Date()));

These query’s give me a total count of records in 2 diff query’s displayed in one field so that I could divide them and get my percentage. These I can get to display on my labels with no errors.

The percentage query is again:

SELECT [qry1]![calls]/[qry2]![CountOfCallID] AS count2
FROM qry1, qry2;



I have a feeling it has something to do with qry1 and qry2 which only display the count of another query. I've then divided them and multiplied the result to get my percentage which is all that’s displayed in the above query. I'm trying to display this percentage in a label in VB6. I am able to display the count queries in a label in VB but not the percentage.

I'm a newbie with VB6 so am not sure how to proceed. I've tried to select the query in the RecordSource, also tried to input the SQL query in the RecordSource but nothing seems to work. BTW the query works great in Access with no errors.

Any help would be greatly appreciated.

Thanks,
Wyatt
  • 0

Advertisements


#2
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
u have to format the thing b4 outputting to the lable

use this

Format(the_variable, "percent")

im guessing u store the result of query into variable

place variable name into the the_Variable spot

put this in b4 u output to the label

if u need more assistance be glad 2
stu Design

for more functions

http://www.officecom...ages/page18.asp

Edited by stu_design, 26 May 2005 - 12:33 PM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP