By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,578 Members | 855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,578 IT Pros & Developers. It's quick & easy.

I want to create a temporary query at runtime

P: 2
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
Share this Question
Share on Google+
3 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
What exactly does the error say?
Jan 8 '08 #2

FishVal
Expert 2.5K+
P: 2,653
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
Expert 100+
P: 897
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

Post your reply

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