Results 1 to 6 of 6
  1. #1
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125

    UPDATE function "too few parameters"

    Trying to update a table value...



    Code:
    Dim dbCMC As DAO.Database
    Dim strSEG As String
    Dim lngSum As Long
    Set dbCMC = CurrentDb
    lngSum = DSum("[DetWgt]", "dbo_tblSubmittals", "[JobNum] = '" & Me.cboJobNum.value & "' And [Segment] = '" & Me.cboSegment.value & "'")
    strSEG = "UPDATE dbo_tblSegments " & _
    "SET [DetWgt] = " & lngSum & " " & _
    "WHERE [JobNum] = '" & Me.cboJobNum.value & "' And [Segment] = '" & Me.cboSegment.value & "'"
    dbCMC.Execute strSEG, dbFailOnError
    It's Erroring on the Execute and saying "too few paramters. Expecting 1". I can't figure out where the problem is, did I forget anything?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Add this line right before the Execute:

    Debug.Print strSEG

    That will print the finished SQL out to the VBA Immediate window. If you don't spot the problem, post the SQL here, along with the data types of the fields.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125
    Already ahead of you, but I didn't notice any problems. Here's the printout

    Code:
    UPDATE dbo_tblSegments SET [DetWgt] = 250000 WHERE [JobNum] = '1123705000' And [Segment] = 'Foundation'
    DetWgt is decimal, JobNum and Segment are text

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I've seen that error when something was spelled wrong too. Double check the spelling of the table and field names. Is that an underscore in the table name, or could it be a space? I suspect that's right, as that's how a SQL Server linked table gets named by default. I always drop the "dbo_" from the linked table, but that's me. If you paste that SQL into an new query and try to run it you might get a more descriptive error.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    eww is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    125
    Paul, I need your direct line, because you always know how to solve my database problems

    pasted the SQL into a new query like you suggested and it instantly told me that the wrong parameter was "Segment" which is actually "Segments" in that table. duh. Thanks for the help.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Access 2003 Date() Function returns "#Name?"
    By smartel@soprema.ca in forum Programming
    Replies: 5
    Last Post: 01-18-2012, 05:52 AM
  2. Replies: 1
    Last Post: 04-06-2011, 04:33 AM
  3. "No Record Found" Function
    By viper in forum Programming
    Replies: 8
    Last Post: 02-09-2011, 09:52 AM
  4. Replies: 3
    Last Post: 04-10-2010, 10:22 AM
  5. Replies: 4
    Last Post: 02-11-2010, 02:21 AM

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