Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    5

    Visual basic Run-time error '3061' Too few parameters, Expected 1

    Can somebody help me, when I want to run my project and I select a customer and a product I get this message. Run-time error '3061' Too few parameters, Expected 1.

    It's in the first sentence I get the error, in "Set ProductRs = EricDb.OpenRecordset(strSQL, dbOpenDynaset)"


    Set ProductRs = EricDb.OpenRecordset(strSQL, dbOpenDynaset)

    ProductRs.Index = "PrimaryKey"

    'Zoek Product
    ProductRs.Seek "=", cmbProducts.ItemData(cmbProducts.ListIndex)

    'product gevonden
    'laat product details zien
    If Not ProductRs.NoMatch Then


    LblPrice.Caption = ProductRs!Artprijs
    LblAmount.Caption = ProductRs!Amount
    End If


    End Sub


    I know it's something with my sql but I have no clue what can be the problem.

    How can I solve this problem ?

  2. #2
    Join Date
    Jul 2003
    Location
    London
    Posts
    5
    This is an error because you have some invalid SQL. Without seeing this, it is impossible to say but the most common problem is if you have referenced a field that does not exist in the database.

    SELECT customet, customer_id FROM customers

    In the above example I am trying to get the "customer" and "customer_id" fields from the "customers" table. I get an error 3061 because I have misspelt customer.

  3. #3
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    5
    but how can i find the problem then ?

    SELECT
    FROM Region INNER JOIN (Amount INNER JOIN (BTWPercentage INNER JOIN (Product INNER JOIN (Customer INNER JOIN ID ON Customer.KlantID = ID.KlantID) ON Product.ArtikelID = ID.ArtikelID) ON BTWPercentage.BTWID = Product.BTWID) ON Amount.EenheidID = Product.EenheidID) ON Region.GemeenteID = Customer.GemeenteID;


    this is the sql

  4. #4
    Join Date
    Jul 2003
    Location
    London
    Posts
    5
    I created a database in Access with the following tables and your SQL worked fine. I think that one of these fields does not exist in the database you will need to check the database.


    Amount.EenheidID

    BTWPercentage.BTWID

    Customer.KlantID
    Customer.GemeenteID

    ID.ArtikelID
    ID.KlantID

    Product.EenheidID
    Product.BTWID
    Product.ArtikelID

    Region.GemeenteID


    (I have used * to get all fields)

    SELECT * FROM Region INNER JOIN (Amount INNER JOIN (BTWPercentage INNER JOIN (Product INNER JOIN (Customer INNER JOIN ID ON Customer.KlantID = ID.KlantID) ON Product.ArtikelID = ID.ArtikelID) ON BTWPercentage.BTWID = Product.BTWID) ON Amount.EenheidID = Product.EenheidID) ON Region.GemeenteID = Customer.GemeenteID


    If you have checked and all are in the database then try:

    Depending on the database you are using and how you are connecting to it, you may be using a reserved word. Try putting square brackets around field and table names (e.g [Amount] and [Amount].[EenheidID])
    Attached Files Attached Files

  5. #5
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    5
    This is weird, I searched but I don't find the problem.

    I will include the program in a zip file so that you can look at it because I don't find the problem.
    Attached Files Attached Files

  6. #6
    Join Date
    Jul 2003
    Location
    London
    Posts
    5
    The problem was with:

    Product.BTWID = BTWPercentage.BTW

    should be:

    Product.BTWID = BTWPercentage.BTWID

    Also, need to remove single quotes here as ArtikelID is not a text field:

    Product.ArtikelID = '" & cmbProducts.ItemData(cmbProducts.ListIndex) & "'

    Also, you will need to use Findfirst rather than Seek because Seek won't work with a dynaset. (See Attached)
    Attached Files Attached Files

  7. #7
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    5
    First thank you for helping me with this. But I have a second question. Why is it not standing in the data grid so that I can print it on a paper ?


    Best Regards

  8. #8
    Join Date
    Jul 2003
    Location
    London
    Posts
    5
    I have never used datagrid before but I would assume that it is supposed to be used with a datacontrol. You have not used any datacontrols in your project and I would suggest that you do not use them because they are not as flexible as using code like you have done so far.
    You will need to see if you can add items into the datagrid control manually by finding some documentation for it. If not then you may have to use a different type of grid. I use an old grid called Apex TDBGrid which I got from the internet. It is good because you can link it to data controls and also add items in manually. This control is years old and there is probably much better stuff out there now.
    You may even have some already on your pc. Go to Project > Components in vb and see if there are any grid controls on your system.

    You could even use the Listview control to show items. This can be found by enabling the "Microsoft Windows Common Controls 6.0" from components screen in vb. You can set the View property to "report" which makes the list look like a grid (without the lines). You will then need to learn about using this control.

    Happy coding...

  9. #9
    Join Date
    Aug 2003
    Location
    Belgium
    Posts
    5
    OK, thanks for helping me

Posting Permissions

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