I few day ago Hans suggest me to export a fields with delimited ";" to use a docmd ...
But i have this prob:
I need to export not all fields but for example field1, field5, ecc... from table1 where field5= ecc...
Is possible to integrate into the command line a string query just created from other use inexisting part of code in my vb6 project?
docmd clear me please
-
- Administrator
- Posts: 78575
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: docmd clear me please
DoCmd.TransferText only works with tables and (stored) queries, not with SQL strings.
One option would be to create a stored query with the SQL that you need, and to export that using DoCmd.TransferText.
Another option would be to open a recordset and to write it to a text file line by line.
One option would be to create a stored query with the SQL that you need, and to export that using DoCmd.TransferText.
Another option would be to open a recordset and to write it to a text file line by line.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
Re: docmd clear me please
"create a stored query..." into the access data base?HansV wrote:DoCmd.TransferText only works with tables and (stored) queries, not with SQL strings.
One option would be to create a stored query with the SQL that you need, and to export that using DoCmd.TransferText.
Another option would be to open a recordset and to write it to a text file line by line.
-
- Administrator
- Posts: 78575
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
Re: docmd clear me please
Ok, and how to integrate into the docmd command line the query nmed Query1?HansV wrote:Yes.
-
- Administrator
- Posts: 78575
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: docmd clear me please
For example:
DoCmd.TransferText acExportDelim, , "Query1", "C:\Documents\MyFile.txt", True
DoCmd.TransferText acExportDelim, , "Query1", "C:\Documents\MyFile.txt", True
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
Re: docmd clear me please
OK perfect test and it work !!!!!!!!!!!!!!!!!HansV wrote:For example:
DoCmd.TransferText acExportDelim, , "Query1", "C:\Documents\MyFile.txt", True
But only a tips.
Admit i have a myquery in access database similar:
select * from my table where filed1="Data"
i know is possible to call via RS.Open "myquery", CONN..ecc but admit Data is a variable is possible to pass this param from my vb6 codfe into query stored in access database?
Peraphs i'm stupid but...
-
- Administrator
- Posts: 78575
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: docmd clear me please
You need the ADOX library for that: set a reference to the "Microsoft ADO Ext. 2.n for DDL and Security" library (the version number depends on your installation).
See Creating and Modifying Stored Queries in Microsoft Access Databases with ADOX
See Creating and Modifying Stored Queries in Microsoft Access Databases with ADOX
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
Re: docmd clear me please
This tips ?:HansV wrote:You need the ADOX library for that: set a reference to the "Microsoft ADO Ext. 2.n for DDL and Security" library (the version number depends on your installation).
See Creating and Modifying Stored Queries in Microsoft Access Databases with ADOX
Modifying a Query
Code: Select all
Sub ModifyQuery(strDBPath As String, _
strQryName As String, _
strSQL As String)
Dim catDB As ADOX.Catalog
Dim cmd As ADODB.Command
Set catDB = New ADOX.Catalog
' Open the Catalog object.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDBPath
Set cmd = New ADODB.Command
' Get the query from the Procedures collection.
Set cmd = catDB.Procedures(strQryName).Command
' Update the query's SQL statement.
cmd.CommandText = strSQL
'Save the updated query.
Set catDB.Procedures(strQryName).Command = cmd
Set catDB = Nothing
End Sub
-
- Administrator
- Posts: 78575
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
Re: docmd clear me please
ops!HansV wrote:Yes, indeed.
Errore 3265(?!)
Last edited by sal21 on 29 Nov 2010, 01:07, edited 1 time in total.
-
- Administrator
- Posts: 78575
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
Re: docmd clear me please
AS USUAL....HansV wrote:For a query, use Views instead of Procedures.