inStr

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

Guest

Hi,
what's the syntax of InStr function when I'm looking a sign ';' in a string.
I'm getting an error all the time.
thanx
alek_mil
 
InStr(1,"some;text",";")

.... or ...

InStr(1, SomeFieldOrVariableName, ";")

.... or ...

InStr(1, SomeFieldOrVariableName, SomeOtherFieldOrVariableName)

In other words, quotes around literal string values, but not around field or
variable names. Put square brackets around field names if they contain
spaces, or if you're using the function in a query or expression and Access
insists on 'helpfully' inserting quotes around the field name for you.

The first 'Start' argument (1 in the examples above) is optional but is
required in some circumstances. As I'm too lazy to try to remember when it
is required and when it isn't, I just always include it.
 
Alek,

Have you tried looking it up in Help??
Syntax

InStr([start, ]string1, string2[, compare])

The InStr function syntax has these arguments:

Part Description
start Optional. Numeric expression that sets the starting position for
each search. If omitted, search begins at the first character position. If
start contains Null, an error occurs. The start argument is required if
compare is specified.
string1 Required. String expression being searched.
string2 Required. String expression sought.
compare Optional. Specifies the type of string comparison. If compare
is Null, an error occurs. If compare is omitted, the Option Compare setting
determines the type of comparison. Specify a valid LCID (LocaleID) to use
locale-specific rules in the comparison.


There's also InstrRev(), which you might look up.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 

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

Same app acts differently on another PC 2
selecting a row from code 1
how to reach field 1
Are the fields nulls? 9
disabling delete/append message 1
filter 1
compact and repair 2
printing two or more reports 1

Back
Top