+ Reply to Thread
Results 1 to 7 of 7

Syntax error due to an apostrophe in string ?

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Syntax error due to an apostrophe in string ?

    Hello everyone. I am currrently working on a project which has me mostly debugging code. I have a user-form that allows
    a user to select from a drop down list a "terminal" (which by-the-way is a list of names of various physical plant facilities:
    e.g. St. John's). After selecting from the drop-down list and after entering other data the user will then press a button called "Save Volumes".
    There is a problem however when a user selects a terminal name that has an apostrophe in it, for instance St. John's, it causes the following error:

    "Syntax error (missing operator) in query expression ...."

    Now just so you know the actual list of terminal name is stored in a Access database, the 1997 version. Below is the code in question
    with an error pointing to the error. Any help is appreciated.

    The "Save Volumes" button code is below:

    Please Login or Register  to view this content.
    Last edited by AnthonyWB; 10-22-2010 at 11:29 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Syntax error due to an apostrophe in string ?

    I suspect you need to replace the ' with a ''

    Please Login or Register  to view this content.
    edit: seems you have done this already re: Product so the above might be moot.

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Syntax error due to an apostrophe in string ?

    I can't realy follow you. I see the code piece you are talking about. Are you sugestig the following correction:

    Replace(Product.Text, " ' ", " ' ' ") corrected to Replace(Product.Text, " ' "," ' ").

    And why will that work ?

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Syntax error due to an apostrophe in string ?

    No, I was suggesting you add what I then realised you already had in place...

    Please Login or Register  to view this content.
    is correct

    If however we're referring here to Terminal rather than Product then you should ape the above for Terminal also.

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Syntax error due to an apostrophe in string ?

    I got you, I think. You are suggesting:

    Please Login or Register  to view this content.
    instead of,

    Please Login or Register  to view this content.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Syntax error due to an apostrophe in string ?

    No, I am suggesting:

    Please Login or Register  to view this content.
    ie encase both Terminal & Product within a Replace [and maybe even SalesOrgToUseForSave if that too can contain apostrophe's]

    You would need to do likewise in your UPDATE statement.

    edit: the point is I am assuming Terminal.Text contains St.John's ... you've not specified that as yet (as far as I can tell)
    Last edited by DonkeyOte; 10-21-2010 at 02:59 PM. Reason: added edit

  7. #7
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Syntax error due to an apostrophe in string ?

    Looks like we got it. Thank you !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1