Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2024
    Posts
    2

    Run-time error: '3061': Too few parameters. Expected 1.

    Hello,

    I do not know why I am getting the run-time error '3061': Too few parameters. Expected 1.

    Below is the code I wrote. I renamed the table and the columns to general terms. The "dbo" table is a SQL Server table that is linked through the Linked Table Manager in Microsoft Access. All connections from the Microsoft Access frontend to the SQL Server backend database are working. The error message occurs on the strSQL when it is used in the dbs.OpenRecordset statement.

    Private Sub Form_Load()




    Dim dbs As DAO.Database, rst As DAO.Recordset, strSQL As String
    Set dbs = CurrentDb
    strSQL = "SELECT [dbo_table].[field1],[dbo_table].[field2] FROM [dbo_table]"
    Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)
    Set Forms("frmABC").Recordset = rst


    End Sub

    As a point of interest, when I change the above code to use only one column, such as [dbo_table].[field1], the code executes without any errors.

    If anyone can solve the issue, it would be most appreciated.

    Thank you.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    These are your actual table and field names?

    Why are you setting Recordset instead RecordSource? Why not just have SQL in form RecordSource property to start with?

    Why pull only 2 fields? Could try * instead.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,945

  4. #4
    Join Date
    Apr 2024
    Posts
    2
    Hi June7,

    Thanks so much!!

    Your suggestion worked.

    All is good.

    I tried a table and then SQL for the record source. They both worked.

    The actual table and field names are different from the ones I posted (table, field1, field2).

    I just used two fields to explain the concept. There are 45 fields that I will pull in using the "*".

    Thanks again for your kind help.

    Edward

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Run-time error '3061'. Too few parameters. Expected 1.
    By Homegrownandy in forum Programming
    Replies: 8
    Last Post: 03-11-2020, 07:17 AM
  2. Replies: 12
    Last Post: 10-20-2019, 08:03 PM
  3. Run-Time Error '3061: Too few parameters. Expected 2.
    By Rickochezz in forum Import/Export Data
    Replies: 1
    Last Post: 11-01-2016, 07:29 AM
  4. Replies: 4
    Last Post: 09-28-2016, 07:13 AM
  5. Replies: 5
    Last Post: 03-27-2015, 03:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums