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. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 18 Times in 18 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.

  3. #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
  •