Results 1 to 4 of 4
  1. #1
    sheusz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2015
    Posts
    151

    Unhappy Too few Paramaters. Expected 2.

    Hi all

    I know this is a syntax issue, but I am struggling to get this statement correct. I have been working on it for hours and am hoping that someone can show me where I am going wrong.


    Code:
    strSQL = "UPDATE [xServices] SET [Onsite Contact] = [Onsite Contact] & ExtNewOnsiteContact WHERE xServices.[MachineNo] = '" & MachineID & "'"
    Table xServices contains Long Text field [Onsite Contact] yes, I know about spaces and field names.

    I want to concatenate [Onsite Contact] & ExtNewOnsiteContact and replace the existing value of [Onsite Contact] where the value of x.Services.[MachineNo] is equal to MachineID.

    MachineID = [Forms]![Training & Services]![Machine No]

    When I Debug.Print strSQL I get this
    UPDATE [xServices] SET [Onsite Contact] = [Onsite Contact] & ExtNewOnsiteContact WHERE xServices.[MachineNo] = '1215-1490'

    but frankly, I'm not sure what I am expected to see.




    In this case MachineID is 1215-1490, so I know that part is correct, so it's probably the concatenation that is wrong.

    Thank you in advance.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Not sure what ExtNewOnsiteContact is but I assume is either a string variable or a form control name, so maybe try:
    Code:
    strSQL = "UPDATE [xServices] SET [Onsite Contact] = [Onsite Contact] & '" & ExtNewOnsiteContact  & "' WHERE xServices.[MachineNo] = '" & MachineID & "'"
    You should also check the name of the MachineNo field in the table, in the form you show it with a space so that might be another part of the error message.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    sheusz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2015
    Posts
    151
    Quote Originally Posted by Gicu View Post
    Not sure what ExtNewOnsiteContact is but I assume is either a string variable or a form control name, so maybe try:
    Code:
    strSQL = "UPDATE [xServices] SET [Onsite Contact] = [Onsite Contact] & '" & ExtNewOnsiteContact  & "' WHERE xServices.[MachineNo] = '" & MachineID & "'"
    You should also check the name of the MachineNo field in the table, in the form you show it with a space so that might be another part of the error message.

    Cheers,
    Thank you for the reply. Your solution was correct on two counts. The syntax, and the xServices.[MachineNo] field is actually xServices.[Machine No]. Talk about missing the bleeding obvious.

    Very much appreciate your help. Have a great day.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    You're very welcome!
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-25-2014, 08:41 AM
  2. pass paramaters to query in saved imports
    By nirvana in forum Import/Export Data
    Replies: 9
    Last Post: 03-15-2013, 07:58 AM
  3. Too few parameters. expected 1.
    By seth1685 in forum Programming
    Replies: 1
    Last Post: 01-11-2012, 08:08 AM
  4. Linking Info/Passing Paramaters?
    By hithere in forum Programming
    Replies: 17
    Last Post: 12-13-2011, 05:30 PM
  5. Too few parameters. Expected 2.
    By PPCMIS2009 in forum Access
    Replies: 0
    Last Post: 01-28-2009, 01:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums