A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SQL string problem



 
 
Thread Tools Display Modes
  #1  
Old June 1st, 2004, 08:45 PM
Gary D.
external usenet poster
 
Posts: n/a
Default SQL string problem

I have a form within which I am trying to define a SQL string via a
string variable (I have also tried defining it as several string
variables and concatenating them, likewise as variant type variables).

I do not get any errors when I concatenate the values, so I am not
exceeding the variable's storage limitations.
According to Access specifications in the Help files, it states that
the maximum Number of characters in an SQL statement = approximately
64,000.
My SQL statement contains 4165 characters.

However, when I try to attach the SQL to the form (e.g. using
Me.RecordSource = varSQL1 & varSQL2 & varSQL3) I receive error message
2176 - "The setting for the property is too long. You can enter up to
either 255 or 2,048 characters for this property, depending on the
data type."
The Help file entry for .RecordSource property doesn't mention a
length limitation, which I guess could be an omission.

Am I correct in concluding that it is the .RecordSource property that
is the problem (stating the obvious, I know, but just to clear up my
confusion)?



---

You're never alone with - schizophrenia!
  #2  
Old June 1st, 2004, 08:51 PM
Rick Brandt
external usenet poster
 
Posts: n/a
Default SQL string problem

"Gary D." wrote in message
...
I have a form within which I am trying to define a SQL string via a
string variable (I have also tried defining it as several string
variables and concatenating them, likewise as variant type variables).

I do not get any errors when I concatenate the values, so I am not
exceeding the variable's storage limitations.
According to Access specifications in the Help files, it states that
the maximum Number of characters in an SQL statement = approximately
64,000.
My SQL statement contains 4165 characters.

However, when I try to attach the SQL to the form (e.g. using
Me.RecordSource = varSQL1 & varSQL2 & varSQL3) I receive error message
2176 - "The setting for the property is too long. You can enter up to
either 255 or 2,048 characters for this property, depending on the
data type."
The Help file entry for .RecordSource property doesn't mention a
length limitation, which I guess could be an omission.

Am I correct in concluding that it is the .RecordSource property that
is the problem (stating the obvious, I know, but just to clear up my
confusion)?


Yes.

You could modify the SQL of a saved query and then just use the name of the
query as your RecordSource.


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


  #3  
Old June 1st, 2004, 09:26 PM
Gary D.
external usenet poster
 
Posts: n/a
Default SQL string problem

On Tue, 1 Jun 2004 14:51:33 -0500, "Rick Brandt"
wrote:

"Gary D." wrote in message
.. .
I have a form within which I am trying to define a SQL string via a
string variable (I have also tried defining it as several string
variables and concatenating them, likewise as variant type variables).

I do not get any errors when I concatenate the values, so I am not
exceeding the variable's storage limitations.
According to Access specifications in the Help files, it states that
the maximum Number of characters in an SQL statement = approximately
64,000.
My SQL statement contains 4165 characters.

However, when I try to attach the SQL to the form (e.g. using
Me.RecordSource = varSQL1 & varSQL2 & varSQL3) I receive error message
2176 - "The setting for the property is too long. You can enter up to
either 255 or 2,048 characters for this property, depending on the
data type."
The Help file entry for .RecordSource property doesn't mention a
length limitation, which I guess could be an omission.

Am I correct in concluding that it is the .RecordSource property that
is the problem (stating the obvious, I know, but just to clear up my
confusion)?


Yes.

You could modify the SQL of a saved query and then just use the name of the
query as your RecordSource.


Yas, thanks. I did have that in palce originally, but I was trying to
hide the SQL from normal viewing, then compile to make an mde front
end (sort of security by obscurity, which I know is not best practice
but it's only a small application).

Thanks anyway.

---

You're never alone with - schizophrenia!
  #4  
Old June 1st, 2004, 11:59 PM
Ted Allen
external usenet poster
 
Posts: n/a
Default SQL string problem

Hi Gary,

In that case, you may be able to use the form's open
event to create a recordset in VBA and then set the forms
recordset equal to it. I don't have any SQL statements as
long as yours to test this with (thank goodness), but it
appears to work with a simple example. Note that I
didn't add any error handlers or anything like that.
Also, you would probably want to close rst in the form's
close event. Following is an example:

Private Sub Form_Open(Cancel As Integer)

Dim StrSQL As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
StrSQL = "Select * FROM tbl"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(StrSQL, dbOpenDynaset)
Set Me.Recordset = rst

End Sub

Hope that helps.

-Ted Allen

-----Original Message-----
On Tue, 1 Jun 2004 14:51:33 -0500, "Rick Brandt"
wrote:

"Gary D." wrote in message
. ..
I have a form within which I am trying to define a

SQL string via a
string variable (I have also tried defining it as

several string
variables and concatenating them, likewise as variant

type variables).

I do not get any errors when I concatenate the

values, so I am not
exceeding the variable's storage limitations.
According to Access specifications in the Help files,

it states that
the maximum Number of characters in an SQL statement

= approximately
64,000.
My SQL statement contains 4165 characters.

However, when I try to attach the SQL to the form

(e.g. using
Me.RecordSource = varSQL1 & varSQL2 & varSQL3) I

receive error message
2176 - "The setting for the property is too long.

You can enter up to
either 255 or 2,048 characters for this property,

depending on the
data type."
The Help file entry for .RecordSource property

doesn't mention a
length limitation, which I guess could be an omission.

Am I correct in concluding that it is

the .RecordSource property that
is the problem (stating the obvious, I know, but just

to clear up my
confusion)?


Yes.

You could modify the SQL of a saved query and then just

use the name of the
query as your RecordSource.


Yas, thanks. I did have that in palce originally, but I

was trying to
hide the SQL from normal viewing, then compile to make

an mde front
end (sort of security by obscurity, which I know is not

best practice
but it's only a small application).

Thanks anyway.

---

You're never alone with - schizophrenia!
.

  #5  
Old June 2nd, 2004, 10:08 PM
Gary D.
external usenet poster
 
Posts: n/a
Default SQL string problem

On Tue, 1 Jun 2004 15:59:04 -0700, "Ted Allen"
wrote:

Hi Gary,

In that case, you may be able to use the form's open
event to create a recordset in VBA and then set the forms
recordset equal to it. I don't have any SQL statements as
long as yours to test this with (thank goodness), but it
appears to work with a simple example. Note that I
didn't add any error handlers or anything like that.
Also, you would probably want to close rst in the form's
close event. Following is an example:

Private Sub Form_Open(Cancel As Integer)

Dim StrSQL As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
StrSQL = "Select * FROM tbl"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(StrSQL, dbOpenDynaset)
Set Me.Recordset = rst

End Sub

Hope that helps.

-Ted Allen

-----Original Message-----
On Tue, 1 Jun 2004 14:51:33 -0500, "Rick Brandt"
wrote:

"Gary D." wrote in message
...
I have a form within which I am trying to define a

SQL string via a
string variable (I have also tried defining it as

several string
variables and concatenating them, likewise as variant

type variables).

I do not get any errors when I concatenate the

values, so I am not
exceeding the variable's storage limitations.
According to Access specifications in the Help files,

it states that
the maximum Number of characters in an SQL statement

= approximately
64,000.
My SQL statement contains 4165 characters.

However, when I try to attach the SQL to the form

(e.g. using
Me.RecordSource = varSQL1 & varSQL2 & varSQL3) I

receive error message
2176 - "The setting for the property is too long.

You can enter up to
either 255 or 2,048 characters for this property,

depending on the
data type."
The Help file entry for .RecordSource property

doesn't mention a
length limitation, which I guess could be an omission.

Am I correct in concluding that it is

the .RecordSource property that
is the problem (stating the obvious, I know, but just

to clear up my
confusion)?

Yes.

You could modify the SQL of a saved query and then just

use the name of the
query as your RecordSource.


Yas, thanks. I did have that in palce originally, but I

was trying to
hide the SQL from normal viewing, then compile to make

an mde front
end (sort of security by obscurity, which I know is not

best practice
but it's only a small application).

Thanks anyway.

---

You're never alone with - schizophrenia!
.


Interesting - I'll give it a try later this week.
Thanks.


---

You're never alone with - schizophrenia!
  #6  
Old June 6th, 2004, 08:53 AM
Gary D.
external usenet poster
 
Posts: n/a
Default SQL string problem

On Tue, 1 Jun 2004 15:59:04 -0700, "Ted Allen"
wrote:

Hi Gary,

In that case, you may be able to use the form's open
event to create a recordset in VBA and then set the forms
recordset equal to it. I don't have any SQL statements as
long as yours to test this with (thank goodness), but it
appears to work with a simple example. Note that I
didn't add any error handlers or anything like that.
Also, you would probably want to close rst in the form's
close event. Following is an example:

Private Sub Form_Open(Cancel As Integer)

Dim StrSQL As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
StrSQL = "Select * FROM tbl"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(StrSQL, dbOpenDynaset)
Set Me.Recordset = rst

End Sub

Hope that helps.

-Ted Allen

-----Original Message-----
On Tue, 1 Jun 2004 14:51:33 -0500, "Rick Brandt"
wrote:

"Gary D." wrote in message
...
I have a form within which I am trying to define a

SQL string via a
string variable (I have also tried defining it as

several string
variables and concatenating them, likewise as variant

type variables).

I do not get any errors when I concatenate the

values, so I am not
exceeding the variable's storage limitations.
According to Access specifications in the Help files,

it states that
the maximum Number of characters in an SQL statement

= approximately
64,000.
My SQL statement contains 4165 characters.

However, when I try to attach the SQL to the form

(e.g. using
Me.RecordSource = varSQL1 & varSQL2 & varSQL3) I

receive error message
2176 - "The setting for the property is too long.

You can enter up to
either 255 or 2,048 characters for this property,

depending on the
data type."
The Help file entry for .RecordSource property

doesn't mention a
length limitation, which I guess could be an omission.

Am I correct in concluding that it is

the .RecordSource property that
is the problem (stating the obvious, I know, but just

to clear up my
confusion)?

Yes.

You could modify the SQL of a saved query and then just

use the name of the
query as your RecordSource.


Yas, thanks. I did have that in palce originally, but I

was trying to
hide the SQL from normal viewing, then compile to make

an mde front
end (sort of security by obscurity, which I know is not

best practice
but it's only a small application).

Thanks anyway.

---

You're never alone with - schizophrenia!
.


Hi Ted,
Well I tried it but it didn't work.
I've given up with this approach. There is only one defined query
anyway and I keep backups, so if it accidentally gets deleted or
amended then I can restore it easily enough.

For info: the reason the SQL statement is so large is that it combines
data from 7 primary related tables and 3 lookup tables. I could break
it down into one main form with corresponding linked subforms as an
altervative, which I might do at some stage in the future.

Thanks for your suggestion.
Gary



---

You're never alone with - schizophrenia!
  #7  
Old June 7th, 2004, 04:02 PM
Ted Allen
external usenet poster
 
Posts: n/a
Default SQL string problem

Bummer, it had worked when I tried it in a test but maybe
there was something different in your db, or maybe it was
the sql length.

But, you may be better using the saved query anyway since
Access will optimize it, vs the sql query that would not.

-Ted Allen
-----Original Message-----
On Tue, 1 Jun 2004 15:59:04 -0700, "Ted Allen"
wrote:

Hi Gary,

In that case, you may be able to use the form's open
event to create a recordset in VBA and then set the

forms
recordset equal to it. I don't have any SQL statements

as
long as yours to test this with (thank goodness), but

it
appears to work with a simple example. Note that I
didn't add any error handlers or anything like that.
Also, you would probably want to close rst in the

form's
close event. Following is an example:

Private Sub Form_Open(Cancel As Integer)

Dim StrSQL As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
StrSQL = "Select * FROM tbl"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(StrSQL, dbOpenDynaset)
Set Me.Recordset = rst

End Sub

Hope that helps.

-Ted Allen

-----Original Message-----
On Tue, 1 Jun 2004 14:51:33 -0500, "Rick Brandt"
wrote:

"Gary D." wrote in message
m...
I have a form within which I am trying to define a

SQL string via a
string variable (I have also tried defining it as

several string
variables and concatenating them, likewise as

variant
type variables).

I do not get any errors when I concatenate the

values, so I am not
exceeding the variable's storage limitations.
According to Access specifications in the Help

files,
it states that
the maximum Number of characters in an SQL

statement
= approximately
64,000.
My SQL statement contains 4165 characters.

However, when I try to attach the SQL to the form

(e.g. using
Me.RecordSource = varSQL1 & varSQL2 & varSQL3) I

receive error message
2176 - "The setting for the property is too long.

You can enter up to
either 255 or 2,048 characters for this property,

depending on the
data type."
The Help file entry for .RecordSource property

doesn't mention a
length limitation, which I guess could be an

omission.

Am I correct in concluding that it is

the .RecordSource property that
is the problem (stating the obvious, I know, but

just
to clear up my
confusion)?

Yes.

You could modify the SQL of a saved query and then

just
use the name of the
query as your RecordSource.

Yas, thanks. I did have that in palce originally, but

I
was trying to
hide the SQL from normal viewing, then compile to make

an mde front
end (sort of security by obscurity, which I know is

not
best practice
but it's only a small application).

Thanks anyway.

---

You're never alone with - schizophrenia!
.


Hi Ted,
Well I tried it but it didn't work.
I've given up with this approach. There is only one

defined query
anyway and I keep backups, so if it accidentally gets

deleted or
amended then I can restore it easily enough.

For info: the reason the SQL statement is so large is

that it combines
data from 7 primary related tables and 3 lookup tables.

I could break
it down into one main form with corresponding linked

subforms as an
altervative, which I might do at some stage in the

future.

Thanks for your suggestion.
Gary



---

You're never alone with - schizophrenia!
.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.