Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Too few parameters (Access 2000)

    My function shows the error Too few parameters.Can you help me find out the error ?

    Public Function Calc()
    Dim StrSQL As String
    Dim pct As Variant
    If Size >= 170 Then
    pct = DLookup("[percent]", "Constants", "[ConstantID] = " & 3)
    ElseIf Size = 20 Then
    pct = DLookup("[percent]", "Constants", "[ConstantID] = " & 2)
    ElseIf Size = 60 Then
    pct = DLookup("[percent]", "Constants", "[ConstantID] = " & 2)
    ElseIf Size < 6 Then
    pct = DLookup("[percent]", "Constants", "[ConstantID] = " & 1)
    End If

    StrSQL = " UPDATE products SET products.grossprice = ([products].[office]+0.5 + pct)"

    CurrentDb.Execute StrSQL

    End Function
    Attached Files Attached Files

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Too few parameters (Access 2000)

    You can't use VBA variables directly in SQL. You must concatenate the SQL string with the value of the variable:

    StrSQL = "UPDATE products SET products.grossprice = ([products].[office]+0.5 + " & pct & ")"

    I can't tell whether this will do what you want, but it should get rid of the error message.

  4. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Too few parameters (Access 2000)

    Thank you ! no errors anymore

Posting Permissions

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