My ERP software is dictating that I use ADO connections. I have been able to convert all my code except when I need to modify a querydef. In DAO it was like this: Sub ReplaceQuery()
Dim dbs As Database, qdf As QueryDef
Set dbs = CurrentDb
dbs.QueryDefs.Refresh
For Each qdf In dbs.QueryDefs
If qdf.Name = "qryMyQuery" Then dbs.QueryDefs.Delete qdf.Name
Next qdf
strSQL = "SELECT * FROM MYDATA;"
Set qdf = dbs.CreateQueryDef("qryMyQuery", strSQL)
DoCmd.OpenQuery qdf.Name, acViewNormal, acReadOnly
Set dbs = Nothing
End Sub
I have simplified my sql statment for demo purposes only, but I must be able to modify a current query def in access 2000 using vba.
I have looked everywhere for weeks with no solution. If anyone can point me in the right direction, I would very much appreciate it.
2 3551
My ERP software is dictating that I use ADO connections. I have been able to convert all my code except when I need to modify a querydef. In DAO it was like this: Sub ReplaceQuery()
Dim dbs As Database, qdf As QueryDef
Set dbs = CurrentDb
dbs.QueryDefs.Refresh
For Each qdf In dbs.QueryDefs
If qdf.Name = "qryMyQuery" Then dbs.QueryDefs.Delete qdf.Name
Next qdf
strSQL = "SELECT * FROM MYDATA;"
Set qdf = dbs.CreateQueryDef("qryMyQuery", strSQL)
DoCmd.OpenQuery qdf.Name, acViewNormal, acReadOnly
Set dbs = Nothing
End Sub
I have simplified my sql statment for demo purposes only, but I must be able to modify a current query def in access 2000 using vba.
I have looked everywhere for weeks with no solution. If anyone can point me in the right direction, I would very much appreciate it.
You can avoid any References to DAO or ADO Object Libraries simply by creating a Base Query consisting of all possible Fields, then modifying the SQL Property of the Query then Opening it. I'm not sure if this will suit your purposes, but hopefully it was worth mentioning. A provided a simple code segment for you to view: -
Dim strNewSQL As String
-
-
strNewSQL = "Select [FirstName], [LastName], [Title] From Employees;"
-
-
CurrentDb.QueryDefs("qryEmployees").SQL = strNewSQL
-
-
DoCmd.OpenQuery "qryEmployees", acViewNormal, acReadOnly
-
You can avoid any References to DAO or ADO Object Libraries simply by creating a Base Query consisting of all possible Fields, then modifying the SQL Property of the Query then Opening it. I'm not sure if this will suit your purposes, but hopefully it was worth mentioning. A provided a simple code segment for you to view: -
Dim strNewSQL As String
-
-
strNewSQL = "Select [FirstName], [LastName], [Title] From Employees;"
-
-
CurrentDb.QueryDefs("qryEmployees").SQL = strNewSQL
-
-
DoCmd.OpenQuery "qryEmployees", acViewNormal, acReadOnly
-
It was very much worth mentioning. My sincere thanks to you. I overlooked the simple solution. Shame on me. Again, thank you.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Shailesh |
last post by:
Hello,
I want to set up some USER DEFINED METRICS in 10g. The restriction
with USER DEFINED METRICS, is the query (or function ) monitoring that
metrics should return only 1 value.
I want to...
|
by: anzenews |
last post by:
Hello!
I have a weird problem... The application I use issues this SQL from
time to time:
alter table t modify id int(6) unique not null auto_increment;
The problem is that this SQL adds a...
|
by: Glenn |
last post by:
Searching through google groups, I have not found anyone able to modify
the query string of a request. I was hoping to make the query string
as short as possible so that a search with many...
|
by: David Emme |
last post by:
Access 97
I have a number of SELECT statements which contain references to
user-defined VBA functions. These typically work as expected, but
occasionally, on one user's machine or another,...
|
by: KevLow |
last post by:
Hi,
Hope some kind soul can help me out here..
I'm trying to programmatically modify the column headings of a crosstab
query such that it can be dynamic based on user specified period (Month...
|
by: Charles Sullivan |
last post by:
I'm working on a program which has a "tree" of command line arguments,
i.e.,
myprogram level1 ]]
such that there can be more than one level2 argument for each level1
argument and more than one...
|
by: alps |
last post by:
Hello friends ,
I am basically a delphi developer and am new to the VB.net
technology.Can anyone out there give me a typical VB.net solution for a
dataentry program for a table.Lets say...
|
by: Bob |
last post by:
Hi all,
I'm trying to import data, modify the data then insert it into a new
table. The code below works fine for it but it takes a really long
time for 15,000 odd records. Is there a way I...
|
by: frostbb |
last post by:
Ok, stumped one more time, I'm trying to learn how to use a DataGridView in
place of the old DataGrid control.
QUESTION: How do I map the columns returned from a RunTime sql query to the
columns...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |