dbTalk Databases Forums  

SQL help

comp.databases.ms-access comp.databases.ms-access


Discuss SQL help in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ron Paii
 
Posts: n/a

Default SQL help - 01-18-2012 , 10:32 AM






I am trying to access a table in a mdb using VBA though a brain dead
program. The problem is it's modifying the the text inside a sql string by
replacing everything bracketed by [ ] with an empty string. I don't know why
and support is?? If I enter the following line in it's editor.

strSql = "SELECT tblParts.[PART#] FROM tblParts WHERE (((tblParts.[PART#]) =
'" & FileName & "'));"

VBA sees the following

strSql = "SELECT tblParts. FROM tblParts WHERE (((tblParts.) = '" & FileName
& "'));"

Is there someway I can reference these fields in SQL by position instead of
name?
If this is not the place, can someone point me to a good SQL group?

Reply With Quote
  #2  
Old   
Bob Barrows
 
Posts: n/a

Default Re: SQL help - 01-18-2012 , 10:51 AM






Ron Paii wrote:
Quote:
I am trying to access a table in a mdb using VBA though a brain dead
program.
Huh?
I think you are actually saying that you are trying to write VBA code in a
brain dead text editor. You need to identify the editor. Why not use the VBA
IDE in Access?

Quote:
The problem is it's modifying the the text inside a sql
string by replacing everything bracketed by [ ] with an empty string.
I don't know why and support is?? If I enter the following line in
it's editor.

strSql = "SELECT tblParts.[PART#] FROM tblParts WHERE
(((tblParts.[PART#]) = '" & FileName & "'));"
Ughhh! Get rid of those unnecessary parentheses! And the semicolon as well -
not needed in JetSQL despite the brainwashing by the Access Query Builder.
tblParts.[PART#] = '" & FileName & "'"
Quote:
VBA sees the following

strSql = "SELECT tblParts. FROM tblParts WHERE (((tblParts.) = '" &
FileName & "'));"
You're saying that the editor you are using is doing this? What editor is
that? I've never seen that happen. Perhaps you need to escape those brackets
so the editor you are using won't process them. The problem is, without
knowing what editor you are using, it's impossible to advise you how to
escape them. It's not VBA doing this so I suspect the VBA escape method
(doubling the characters that you want to be treated literally) would work.
It can't hurt to try:
.... tblParts.[[PART#]] ...

I suppose it can't hurt to try the java escape method:
.... tblParts.\[PART#\] ...

Quote:
Is there someway I can reference these fields in SQL by position
instead of name?
No.

Quote:
If this is not the place, can someone point me to a good SQL group?
If by "SQL", you mean "SQL Server", then there are a couple in usenet that
are easily found. If you are talking about JetSQL,. then this group is as
good as any. This is not really a "SQL" question, anyways - it's a question
about the text editor you are using.

Reply With Quote
  #3  
Old   
Patrick Finucane
 
Posts: n/a

Default Re: SQL help - 01-18-2012 , 11:04 AM



On Jan 18, 10:51*am, "Bob Barrows" <reb01... (AT) NOyahooSPAM (DOT) com> wrote:
Quote:
Ron Paii wrote:
I am trying to access a table in a mdb using VBA though a brain dead
program.

Huh?
I think you are actually saying that you are trying to write VBA code in a
brain dead text editor. You need to identify the editor. Why not use the VBA
IDE in Access?

The problem is it's modifying the the text inside a sql
string by replacing everything bracketed by [ ] with an empty string.
I don't know why and support is?? If I enter the following line in
it's editor.

strSql = "SELECT tblParts.[PART#] FROM tblParts WHERE
(((tblParts.[PART#]) = '" & FileName & "'));"

Ughhh! Get rid of those unnecessary parentheses! And the semicolon as well -
not needed in JetSQL despite the brainwashing by the Access Query Builder..
tblParts.[PART#] = '" & FileName & "'"



VBA sees the following

strSql = "SELECT tblParts. FROM tblParts WHERE (((tblParts.) = '" &
FileName & "'));"

You're saying that the editor you are using is doing this? What editor is
that? I've never seen that happen. Perhaps you need to escape those brackets
so the editor you are using won't process them. The problem is, without
knowing what editor you are using, it's impossible to advise you how to
escape them. It's not VBA doing this so I suspect the VBA escape method
(doubling the characters that you want to be treated literally) would work.
It can't hurt to try:
... tblParts.[[PART#]] ...

I suppose it can't hurt to try the java escape method:
... tblParts.\[PART#\] ...



Is there someway I can reference these fields in SQL by position
instead of name?

No.

If this is not the place, can someone point me to a good SQL group?

If by "SQL", you mean "SQL Server", then there are a couple in usenet that
are easily found. If you are talking about JetSQL,. then this group is as
good as any. This is not really a "SQL" question, anyways - it's a question
about the text editor you are using.
I know that the #, useful for date fields, can make things to appear
as a hyperlink field. I'd check to see if the field name Part#, if
changed to PartNo or PartNum, makes a difference.

Reply With Quote
  #4  
Old   
Bob Barrows
 
Posts: n/a

Default Re: SQL help - 01-18-2012 , 11:18 AM



Ron Paii wrote:
Quote:
I am trying to access a table in a mdb using VBA though a brain dead
program. The problem is it's modifying the the text inside a sql
string by replacing everything bracketed by [ ] with an empty string.
I don't know why and support is?? If I enter the following line in
it's editor.

strSql = "SELECT tblParts.[PART#] FROM tblParts WHERE
(((tblParts.[PART#]) = '" & FileName & "'));"

VBA sees the following

strSql = "SELECT tblParts. FROM tblParts WHERE (((tblParts.) = '" &
FileName & "'));"

Is there someway I can reference these fields in SQL by position
instead of name?
No, but if you create this as a saved parameterized query, you can greatly
simplify your code. Here is a post I made about this method:
http://groups.google.com/group/micro...eb98f331?pli=1

Reply With Quote
  #5  
Old   
Ron Paii
 
Posts: n/a

Default Re: SQL help - 01-18-2012 , 12:43 PM



"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote

Quote:
Ron Paii wrote:
I am trying to access a table in a mdb using VBA though a brain dead
program.

Huh?
I think you are actually saying that you are trying to write VBA code in a
brain dead text editor. You need to identify the editor. Why not use the
VBA
IDE in Access?

No it is not Access, it's a brain dead program;(
It has a feature called advanced scripting which is VBA but it only supplies
a text editor for writing code. It then exports that code into VBA after
apply it's version of macro replacement for any text within []. By adding
"Debug.Assert False" to the code, the VBA editor opened and I could see the
code. The fix was to use chr(91) and chr(93).

Quote:
Is there someway I can reference these fields in SQL by position
instead of name?

No.

If this is not the place, can someone point me to a good SQL group?

If by "SQL", you mean "SQL Server", then there are a couple in usenet that
are easily found. If you are talking about JetSQL,. then this group is as
good as any. This is not really a "SQL" question, anyways - it's a
question
about the text editor you are using.


The SQL question would be a alternate way to reference the fields using
legal SQL syntax.


Thank you for your help.

Reply With Quote
  #6  
Old   
Bob Barrows
 
Posts: n/a

Default Re: SQL help - 01-18-2012 , 02:15 PM



Ron Paii wrote:
Quote:
"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote in message
news:jf6tbi$n1h$1 (AT) dont-email (DOT) me...
Ron Paii wrote:
I am trying to access a table in a mdb using VBA though a brain dead
program.

Huh?
I think you are actually saying that you are trying to write VBA
code in a brain dead text editor. You need to identify the editor.
Why not use the VBA
IDE in Access?


No it is not Access, it's a brain dead program;(
It has a feature called advanced scripting which is VBA but it only
supplies a text editor for writing code. It then exports that code
into VBA
You talk like VBA is a program that one can export code into (it isn't). Do
you mean that it's inserting the code into an Access VBA module? if so, I
still don't understand why you're not doing this in Access.

Is your editor creating an executable program? If so, it's not exporting the
code "into VBA", it's compiling an executable program that probably uses the
VB Runtime dll to execute - in which case, it's not VBA, it's VB.

Reply With Quote
  #7  
Old   
Ron Paii
 
Posts: n/a

Default Re: SQL help - 01-18-2012 , 02:26 PM



"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote

Quote:
Ron Paii wrote:
"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote in message
news:jf6tbi$n1h$1 (AT) dont-email (DOT) me...
Ron Paii wrote:
I am trying to access a table in a mdb using VBA though a brain dead
program.

Huh?
I think you are actually saying that you are trying to write VBA
code in a brain dead text editor. You need to identify the editor.
Why not use the VBA
IDE in Access?


No it is not Access, it's a brain dead program;(
It has a feature called advanced scripting which is VBA but it only
supplies a text editor for writing code. It then exports that code
into VBA

You talk like VBA is a program that one can export code into (it isn't).
Do
you mean that it's inserting the code into an Access VBA module? if so, I
still don't understand why you're not doing this in Access.

Is your editor creating an executable program? If so, it's not exporting
the
code "into VBA", it's compiling an executable program that probably uses
the
VB Runtime dll to execute - in which case, it's not VBA, it's VB.


I am referencing a table in a MDB file from a CAD program to get information
for use with that program. That program's maco / script editor is a simple
text editor. The code is looks identical to VBA. When I added the
"Debug.Assert False" and ran the code. A VBA style editor opened, showing
the modified code. I can only guess the program is making the changes in the
background, then opening VBA then importing and running the code.

Reply With Quote
  #8  
Old   
Bob Barrows
 
Posts: n/a

Default Re: SQL help - 01-18-2012 , 02:39 PM



Ron Paii wrote:
Quote:
I am referencing a table in a MDB file from a CAD program to get
information for use with that program. That program's maco / script
editor is a simple text editor. The code is looks identical to VBA.
That's not conclusive. VBA looks an awful lot like VB ... the main
difference is
there are extra application-specific functions in VBA - such as Nz(). Can
you
use Nz in code written by this editor?

Quote:
When I added the "Debug.Assert False" and ran the code. A VBA style
editor opened, showing the modified code. I can only guess the
program is making the changes in the background, then opening VBA
then importing and running the code.
Again, you cannot "open" VBA. VBA is not a program that can be opened. It is
an execution environment suppled by a dll. Office programs supply an
Integrated Development Environment (IDE) that is used to edit and debug
code. The IDE is not executing the code: it compiles the text and passes the
compilation to the VBA dll which does the execution. I suspect your CAD
program is doing something similar.

Reply With Quote
  #9  
Old   
Ron Paii
 
Posts: n/a

Default Re: SQL help - 01-18-2012 , 03:28 PM



"Bob Barrows" <reb01501 (AT) NOyahooSPAM (DOT) com> wrote

Quote:
Ron Paii wrote:
I am referencing a table in a MDB file from a CAD program to get
information for use with that program. That program's maco / script
editor is a simple text editor. The code is looks identical to VBA.

That's not conclusive. VBA looks an awful lot like VB ... the main
difference is
there are extra application-specific functions in VBA - such as Nz(). Can
you
use Nz in code written by this editor?

When I added the "Debug.Assert False" and ran the code. A VBA style
editor opened, showing the modified code. I can only guess the
program is making the changes in the background, then opening VBA
then importing and running the code.

Again, you cannot "open" VBA. VBA is not a program that can be opened. It
is
an execution environment suppled by a dll. Office programs supply an
Integrated Development Environment (IDE) that is used to edit and debug
code. The IDE is not executing the code: it compiles the text and passes
the
compilation to the VBA dll which does the execution. I suspect your CAD
program is doing something similar.



VBA may be integrated into the program, but they failed to provide the
interface. I know VB is not on my computer.

Reply With Quote
  #10  
Old   
FarAway@LongAgo
 
Posts: n/a

Default Re: SQL help - 01-18-2012 , 04:18 PM



On Wed, 18 Jan 2012 10:32:30 -0600, "Ron Paii" <None (AT) none (DOT) com> wrote:

Quote:
I am trying to access a table in a mdb using VBA though a brain dead
program. The problem is it's modifying the the text inside a sql string by
replacing everything bracketed by [ ] with an empty string. I don't know why
and support is?? If I enter the following line in it's editor.

strSql = "SELECT tblParts.[PART#] FROM tblParts WHERE (((tblParts.[PART#]) =
'" & FileName & "'));"

VBA sees the following

strSql = "SELECT tblParts. FROM tblParts WHERE (((tblParts.) = '" & FileName
& "'));"

Is there someway I can reference these fields in SQL by position instead of
name?
If this is not the place, can someone point me to a good SQL group?
If you change PART# to PARTNUM and omit all the square brackets (which
are only required if the field name is not a single word) then maybe
that will work.
Also some of the round backets and the semicolon are also not required
as already pointed out but they don't seem to be doing any harm.
HTH

Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.