Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Too few parameters (Access 2000)

    Can somebody help me with rewriting and old function with a newer one? I have a function for updating orders called
    UpdateOrders, where on the OnClick event i write updateOrders "orders.orderid = " & Screen.ActiveControl.Value.
    Now i want to get rid of this function and build a new function called New() in a form which has a control called ProductID.
    My where clause will be strWhere = " ProductID= " & Me.Productid.
    Unfortunately i receive the error Too few parameters

    Public Function UpdateOrders(ByVal strWhere As String)
    ' the following in the OnClick event:
    ' updateOrders "orders.orderid = " & Screen.ActiveControl.Value
    Dim strBas As String

    StrBas = "UPDATE orders INNER JOIN (products INNER JOIN " & " [order details] ON (products.Productid = [order details].ProductID) " & "AND

    (products.Productid = [order details].ProductID)) " & "ON orders.orderid = [order details].OrderID SET " & "products.stock = products.stock+[order

    details].cartons " & "WHERE " & strWhere
    ==================================
    ==========================

    Private Function New()
    Dim strWhere As String
    strWhere = " ProductID= " & Me.Productid
    Dim strBas As String


    strBas = "UPDATE orders INNER JOIN (products INNER JOIN " & " [order details] ON (products.Productid = [order details].ProductID) " & "AND

    (products.Productid = [order details].ProductID)) " & "ON orders.orderid = [order details].OrderID SET " & "products.stock = products.stock+[order

    details].cartons & strWhere"


    CurrentDb.Execute strBas

    End Function

  2. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Too few parameters (Access 2000)

    I believe new is a reserved word. So I would suggest changing new to fNew or new1. I have no idea if naming a function after a reserved word causes problems! But generally it's not a good idea to name anything after a reserved word.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Too few parameters (Access 2000)

    Use descriptive names for your routines. "UpdateOrders" is a descriptive name, but "New" is meaningless. Besides, as Rupert pointed out, it is a reserved word in Access/VBA and its use can lead to unexpected results, if not downright errors. You also need to specify the table name for productID in your strWhere since you have the same field name in both tables.
    Charlotte

Posting Permissions

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