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

help with recordset creation

I have tested two queries in the query grid and want to create a dynamic
string in vba and then create one recordset that returns the same but cannot
quite get my head around one sql string that will do the same. Q2 just
groups and does a count on Q1.

Many regards in advance

Q1 :

SELECT Qrygetyearsofbookings_1.[Year From],
Count(Qrygetyearsofbookings_1.[DOSM-DSName]) AS [CountOfDOSM-DSName]
FROM Qrygetyearsofbookings AS Qrygetyearsofbookings_1
GROUP BY Qrygetyearsofbookings_1.[Year From];
Q2:

SELECT Format([From],"yyyy") AS [Year From], DOSMBK.[DOSM-DSName]
FROM DOSMBK
GROUP BY Format([From],"yyyy"), DOSMBK.[DOSM-DSName]
HAVING (((DOSMBK.[DOSM-DSName]) Like "M9S" Or
(DOSMBK.[DOSM-DSName])="M9SA"));

Nov 13 '05 #1
2 1166
is there a problem with opening a query off a stored querydef? Going
that way is probably the easiest... failing that, build your query
with the QBE grid, copy the SQL and paste it into a string variable,
and replace all double quotes with singles (using the Replace
function). Then you can open a recordset by opening a recordset that
has a SQL string as a source.
Nov 13 '05 #2
I did that late last night in the end I just thought it was more elegant not
to have to use queries in the database as the previous developer has 1000 of
them and so I preferred to do them dynamically. I never knew that I could
use a recordset as the source for a recordset.

what is the syntax in this case

Your advice is not wasted thank you very much Pieter.
"Pieter Linden" <pi********@hotmail.com> wrote in message
news:bf**************************@posting.google.c om...
is there a problem with opening a query off a stored querydef? Going
that way is probably the easiest... failing that, build your query
with the QBE grid, copy the SQL and paste it into a string variable,
and replace all double quotes with singles (using the Replace
function). Then you can open a recordset by opening a recordset that
has a SQL string as a source.

Nov 13 '05 #3

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

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
6
by: HKM | last post by:
Hello, I have a query engine that builds the SQL Query to obtain the recordSet. Following is an Exmaple Query that my QueryBuilder outputted SELECT * FROM BookInfo WHERE BookName LIKE...
2
by: Patrick Gonzalez | last post by:
Is it possible to use the built-in filter functions (ie. "Filter by Selection", etc..) when a form's recordsource has been set to a recordset object during the load event. When I try to do this, I...
12
by: Jozef | last post by:
Hello, Does anyone here know for sure, when you do a For Each loop on a forms controls collection, does Access cycle through them in Alphabetical order or control ID or ???. Any ideas? ...
2
by: roz | last post by:
Hello, I'm fairly new to VB programming and I've been going round the bend with this problem, so any nudges or shoves in the right direction would be greatly appreciated. I have a template...
10
by: Roger Withnell | last post by:
I'm using ASP, VBScript and SQL Server. I'm also using UTF-8 character set and so my codepage is 65001 and SQL Server datatype nvarchar. I can insert unicode characters correctly into the...
15
by: Simon Gare | last post by:
Hi, trying to retrieve postal codes from the db but only want the query to look at the first 3 digits of the code tried using (LEFT(dbo.booking_form.COLL_POST_CODE),3) but that doesn't work. I...
0
by: =?Utf-8?B?UmFodnlu?= | last post by:
I am working on a COM dll in C# that needs to pass an ADODB recordset back to the calling VBScript. I believe I have everthing setup correctly, as the calls work, and it looks like a recordset is...
7
by: tnjarrett | last post by:
Hello, I have a MS Access continuous subform that was using a query as the recordsource. I changed it to use a recordset instead because when the query was used, the changes to the subform values...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.