Dynamic Queries In MS-Access

  • Thread starter Thread starter arunachalam.arcot
  • Start date Start date
A

arunachalam.arcot

Hi, I'm trying to create a dynamic query in MS-Access. I have a table
with 3 fields and my dynamic query will be constructed with those 3
fields. Since I haven't done this before, I searched for help in this
forum and tried to use some, but still I'm getting errors. Can anyone
help me with this?

Find below the code which I'm using.


Sub Defaults()


Dim sql As String
sql = "select count(*) from " & Default_value.Table_name & " where" &

Default_value.Field_Name & "=" & Default_value.Default
CurrentDb.Querydefs("SomeQuery").sql = sql


End Sub


Thanks
Arun
 
Hi, I'm trying to create a dynamic query in MS-Access. I have a table
with 3 fields and my dynamic query will be constructed with those 3
fields. Since I haven't done this before, I searched for help in this
forum and tried to use some, but still I'm getting errors. Can anyone
help me with this?

Find below the code which I'm using.


Sub Defaults()


Dim sql As String
sql = "select count(*) from " & Default_value.Table_name & " where" &

Default_value.Field_Name & "=" & Default_value.Default
CurrentDb.Querydefs("SomeQuery").sql = sql


"I'm getting errors" really doesn't give us much information
to work with.

Lacking any details, all I can see is that you are missing a
space after the word where

Note for the future, please use Copy/Paste to post your
code/queries so we don't waste a lot of effort debugging
your typos.
 
Back
Top