query or SQL string

V

Vsn

Hi all,

In below code, would it be possible to change the recordset, by means of a
SQL statment in the string MySQL, with an query name?

'Data export section
Dim dbCurr As DAO.Database
Dim rsCurr As DAO.Recordset
Dim fldCurr As DAO.Field
Dim intCurrColumn As Integer

Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset(MySQL)
If rsCurr.BOF = False And rsCurr.EOF = False Then
intCurrColumn = 1
With objActiveWksh
For Each fldCurr In rsCurr.Fields
.Cells(1, intCurrColumn) = fldCurr.Name
intCurrColumn = intCurrColumn + 1
Next fldCurr
.Cells(2, 1).CopyFromRecordset rsCurr
End With
End If

I would like to make a routine which accepts a query or an SQL string.

Thanks for advice,
Ludovic
 
A

Allen Browne

Yes: you can use a query name.

It won't work if the query contains names that require the Expression
Service to resolve -- names such as:
[Forms].[Form1].[Text0]
 
V

Vsn

Sorry i do react a bit late, i have been out.

I have a remaining question, it (code below) works fine with the queries and
SQL stings, but I remain to have troubles to export MEMO type fields. I do
have a 'large' table and subsequently a query or sql-string that crasches
when i do include the memo field. The memo field is filled with all kind
text just pasted into it. What could be the reason? Are the sertain
characters in the memo field which cause this to happen?

Thx,
Ludovic


Allen Browne said:
Yes: you can use a query name.

It won't work if the query contains names that require the Expression
Service to resolve -- names such as:
[Forms].[Form1].[Text0]

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Vsn said:
Hi all,

In below code, would it be possible to change the recordset, by means of
a SQL statment in the string MySQL, with an query name?

'Data export section
Dim dbCurr As DAO.Database
Dim rsCurr As DAO.Recordset
Dim fldCurr As DAO.Field
Dim intCurrColumn As Integer

Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset(MySQL)
If rsCurr.BOF = False And rsCurr.EOF = False Then
intCurrColumn = 1
With objActiveWksh
For Each fldCurr In rsCurr.Fields
.Cells(1, intCurrColumn) = fldCurr.Name
intCurrColumn = intCurrColumn + 1
Next fldCurr
.Cells(2, 1).CopyFromRecordset rsCurr
End With
End If

I would like to make a routine which accepts a query or an SQL string.

Thanks for advice,
Ludovic
 
A

Allen Browne

Not sure what might be causing the crash.

There are several issues with memos (particularly if you aggregate on them),
and many other things that can cause JET queries to crash such as:
http://allenbrowne.com/NoYesNo.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Vsn said:
Sorry i do react a bit late, i have been out.

I have a remaining question, it (code below) works fine with the queries
and SQL stings, but I remain to have troubles to export MEMO type fields.
I do have a 'large' table and subsequently a query or sql-string that
crasches when i do include the memo field. The memo field is filled with
all kind text just pasted into it. What could be the reason? Are the
sertain characters in the memo field which cause this to happen?

Thx,
Ludovic


Allen Browne said:
Yes: you can use a query name.

It won't work if the query contains names that require the Expression
Service to resolve -- names such as:
[Forms].[Form1].[Text0]

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Vsn said:
Hi all,

In below code, would it be possible to change the recordset, by means of
a SQL statment in the string MySQL, with an query name?

'Data export section
Dim dbCurr As DAO.Database
Dim rsCurr As DAO.Recordset
Dim fldCurr As DAO.Field
Dim intCurrColumn As Integer

Set dbCurr = CurrentDb()
Set rsCurr = dbCurr.OpenRecordset(MySQL)
If rsCurr.BOF = False And rsCurr.EOF = False Then
intCurrColumn = 1
With objActiveWksh
For Each fldCurr In rsCurr.Fields
.Cells(1, intCurrColumn) = fldCurr.Name
intCurrColumn = intCurrColumn + 1
Next fldCurr
.Cells(2, 1).CopyFromRecordset rsCurr
End With
End If

I would like to make a routine which accepts a query or an SQL string.

Thanks for advice,
Ludovic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top