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

I want to create a temporary query at runtime

I want to create a temporary query at runtime. I am using CreateQueryDef but compilation error comming. I have used the following coding
Expand|Select|Wrap|Line Numbers
  1.    Set database = CodeDb
  2.  
  3.    Dim dbsSunData As database
  4.    Dim qdfTemp As QueryDef
  5.    Dim qdfNew As QueryDef
  6.  
  7.    Set dbsSunData = OpenDatabase("sunlinkdata.mdb")
  8.  
  9.    With dbsSunData
  10.       ' Create temporary QueryDef.
  11.       Set qdfTemp = SunLinkData.CreateQueryDef("cldata", _
  12.           "SELECT Location, accnt_code, exprperiod, trans_date, amount, d_c, due_date, expralloc_ref " & _
  13.           "FROM salfldgvil " & _
  14.           "WHERE (accnt_code >='" & Trim(Me.cboPartyCodeFr.Value) & "' AND " & _
  15.                  "accnt_code <= '" & Trim(Me.cboPartycodeTo.Value) & "') AND " & _
  16.                  "(trans_date >= #" & Me.dtpTranDtFrom.Value & "# AND " & _
  17.                  "trans_date <= " & Me.dtpTranDateTo.Value & _
  18.                  "#) ORDER BY alloc_ref, d_c")
  19.  
Can you please help me.
Jan 8 '08 #1
3 6884
MMcCarthy
14,534 Expert Mod 8TB
What exactly does the error say?
Jan 8 '08 #2
FishVal
2,653 Expert 2GB
Hi, there.

Your variable SunLinkData supposed to be DAO.Database object was not declared nor initialized. Change it to dbsSunData or remove at all as soon as the instruction is within
Expand|Select|Wrap|Line Numbers
  1. With dbsSunData
  2. End With
  3.  
block.
Jan 8 '08 #3
Jim Doherty
897 Expert 512MB
I want to create a temporary query at runtime. I am using CreateQueryDef but compilation error comming. I have used the following coding
Expand|Select|Wrap|Line Numbers
  1. Set database = CodeDb
  2.  
  3. Dim dbsSunData As database
  4. Dim qdfTemp As QueryDef
  5. Dim qdfNew As QueryDef
  6.  
  7. Set dbsSunData = OpenDatabase("sunlinkdata.mdb")
  8.  
  9. With dbsSunData
  10. ' Create temporary QueryDef.
  11. Set qdfTemp = SunLinkData.CreateQueryDef("cldata", _
  12. "SELECT Location, accnt_code, exprperiod, trans_date, amount, d_c, due_date, expralloc_ref " & _
  13. "FROM salfldgvil " & _
  14. "WHERE (accnt_code >='" & Trim(Me.cboPartyCodeFr.Value) & "' AND " & _
  15. "accnt_code <= '" & Trim(Me.cboPartycodeTo.Value) & "') AND " & _
  16. "(trans_date >= #" & Me.dtpTranDtFrom.Value & "# AND " & _
  17. "trans_date <= " & Me.dtpTranDateTo.Value & _
  18. "#) ORDER BY alloc_ref, d_c")
  19.  
Can you please help me.
In addition ........ amend this
Set qdfTemp = SunLinkData.CreateQueryDef

to read

Set qdfTemp = dbsSunData.CreateQueryDef


Jim :)
Jan 11 '08 #4

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

Similar topics

4
by: Tom Rathbun | last post by:
This is probably simple but it has stumped me. I want to create objects at runtime for example: A program that would allow you to draw lines on a form. For each new line I would like to create a...
0
by: Russell R Snella | last post by:
------=_NextPart_000_0000_01C35111.935D6050 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello, Mysql Version 4.0.11a-gamma When I try and run the...
6
by: sheree | last post by:
I would like to create a query where one of the columns of the queries comes from a combo list box on a form. For example, if my table has the following fields: id name interest1 interest2...
3
by: Gekko . via AccessMonster.com | last post by:
I want to create a query that the first field should be an autonumber. For example I want the name and last name from the Emp table, but I want that the first field is an autonumber that identifies...
13
by: invincible | last post by:
hi friends , how can I declare / create function during runtime similiar to lambda in lisp. thanks Mohan
2
by: Kiko + | last post by:
Hi, I've been getting this error: Server Error in '/applicationname' Application. ---------------------------------------------------------------------------- ---- Failed to create...
0
by: mktilu | last post by:
hi can any one give me a example to create temporary table in Stored procedure during run time and then delete the temporary table at the end of the stored procedure .its argent
24
by: Dan2kx | last post by:
Hello to all that read and thank you to all that post Background: I have been tasked to create a holiday database for the employees in my lab, (so expect many more posts) im stuck at the first...
2
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I am using vb.net 2005 and the following code trying to create varible at runtime: For n=1 to 4 dim v+n.tostring(n) as double Next n the resone behaind using the previous...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.