Using * in an SQL Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I hope someone can help me with this. I inherited this database that I need
to include its table into another database. Things have gone smoothly except
when it comes to adding a new record into this table. The "Key" field is
made up of a letter code, the last digit of the fiscal year, and then a three
digit number. Up until a few weeks ago the fiscal year digit came before the
letter code, then the three digit number. The three digit number can be
repeated as long as it's not repeated with the same code letter. For example
I might have a code "5B102" and "5C102". Since I need to keep this format I
want to find the highest number in each letter group so I can increment it,
then created a new Record Identifier based on the incremented number. I'm
trying to find the highest record using an SQL statement in VBA, example:
"Select [CANumber] frm [tbl FA] where [CANumber] like '" & Chr(42) & X &
Chr(42) & "'". I have done a lot of SQL statements using the wild card this
way, but this time it doesn't like the "like" portion. I have gone into the
Query Builder, created the query, and it ran fine. When I pasted that into
my code, it won't work. Does anyone have any clues what I might be doing
wrong this time or why it won't work this way? Thanks.
 
No, that didn't work either. Any other suggestions? Thanks.

JohnFol said:
Why not do

Like "?X*"


Elaine said:
I hope someone can help me with this. I inherited this database that I
need
to include its table into another database. Things have gone smoothly
except
when it comes to adding a new record into this table. The "Key" field is
made up of a letter code, the last digit of the fiscal year, and then a
three
digit number. Up until a few weeks ago the fiscal year digit came before
the
letter code, then the three digit number. The three digit number can be
repeated as long as it's not repeated with the same code letter. For
example
I might have a code "5B102" and "5C102". Since I need to keep this format
I
want to find the highest number in each letter group so I can increment
it,
then created a new Record Identifier based on the incremented number. I'm
trying to find the highest record using an SQL statement in VBA, example:
"Select [CANumber] frm [tbl FA] where [CANumber] like '" & Chr(42) & X &
Chr(42) & "'". I have done a lot of SQL statements using the wild card
this
way, but this time it doesn't like the "like" portion. I have gone into
the
Query Builder, created the query, and it ran fine. When I pasted that
into
my code, it won't work. Does anyone have any clues what I might be doing
wrong this time or why it won't work this way? Thanks.
 

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

Similar Threads

search criteria in query 7
Query Inside an SQL statement 3
Selecting Values with the Letter P 2
SQL query 1
SQL query 1
trim first letter to leave number 4
Sorting 0
2 functions 1 field in an append query 1

Back
Top