Consulting

Results 1 to 4 of 4

Thread: need help with VBA / MSACCESS code

  1. #1

    need help with VBA / MSACCESS code

    I'm trying to retireve a value from Access table using the following code:

    Private Sub VATType_lostfocus()


    Me.Refresh
    Set a = CurrentDb.OpenRecordset("select sum([Rate]) from VATTyp where [VType] = " & Me.VATType & "")

    End Sub

    But I get the following error: Run-Time error 3061. Too few parameters. Expected 1

    Please help to resolve.

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Is that the total fo your code?
    As there are no dim statements and no error trapping.
    Is this recordset based on a query?
    Are the field names spelt correctly?
    An example database with a small amount of dummy data would be very helpful.

  3. #3
    Quote Originally Posted by OBP View Post
    Is that the total fo your code?
    As there are no dim statements and no error trapping.
    Is this recordset based on a query?
    Are the field names spelt correctly?
    An example database with a small amount of dummy data would be very helpful.
    yes this is the total code
    is the dim statement required?
    recordset is based on table
    field names are spelled correctly.

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Well, Variables and Objects should always be Dimensioned to tell the Access VBA what to expect when they are used.
    On top of that you should also be using Error trapping to ensure that errors are reproted correctly and stop you get in an error loop.
    So can you explain what you are going to use this value for when you get it?

Posting Permissions

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