Results 1 to 4 of 4
  1. #1
    Tim1 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    2

    Create Querydef - Error 3265

    I am really struggling to use an append query with parameters
    I believe that I need to use a QueryDef, but am struggling with this as I have never used one before.
    So I am appealing for help!


    I have attached a stripped down version of my database
    Open form "frmPrintGP"
    Select a record for each combo box (top on first)
    Hit the command button "Append Data"
    The "qryAppendTotblQueryData" should run, but I keep getting the error 3265- Too few parameters

    I really would appreciate it someone could educate me!

    Many thanks in advance
    Attached Files Attached Files

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    You can't run an update query with that syntax.
    Instead of CurrentDb.Execute "qryAppendTotblQueryData", dbFailOnError
    Use
    DoCmd.OpenQuery "
    qryAppendTotblQueryData"

  3. #3
    Tim1 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2016
    Posts
    2
    Quote Originally Posted by davegri View Post
    You can't run an update query with that syntax.
    Instead of CurrentDb.Execute "qryAppendTotblQueryData", dbFailOnError
    Use
    DoCmd.OpenQuery "
    qryAppendTotblQueryData"
    Thanks very much.
    Problem solved

    Just interested to know why Access does not allow the syntax "CurrentDb.Execute......"

  4. #4
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    You can't run an update query with that syntax.
    Instead of CurrentDb.Execute "qryAppendTotblQueryData", dbFailOnError
    Are you positive, 'cause I'm not. CurrentDb.Execute is only for action queries, and Update is an action query. I think the issue is that you can't use the execute method on an action query that has parameters without defining and providing the parameter values. If the query has form references as parameters, I agree it's simpler to use the OpenQuery method. However, I've read where DoCmd.Open query was created to provide datasheets from queries and just happens to run an action query (if it does not need parameters from VBA). What I don't remember is if it eliminates the prompts from action queries. The Execute method prevents warnings, or having to cycle them on/off, plus if there are errors, it does not complete, which certainly can be valuable when it comes to action queries. The db I downloaded has no code for the button click event:
    Private Sub cmdAppendData_Click()

    End Sub

    so I'm going by what I see in the only query in the db. Tim1, to execute a query in VBA, you typically create a QueryDef object, Parameter variables and assign the parameters to the object. There are many places you can read up on this (some of them go into way too much stuff for what you need, I think). Take a look at this simple sample starting with post #2. http://www.access-programmers.co.uk/...d.php?t=191614
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Run-Time Error '3265': Item Not Found In This Collection
    By Voodeux2014 in forum Programming
    Replies: 3
    Last Post: 01-29-2016, 09:04 AM
  2. Remove querydef
    By Ruegen in forum Programming
    Replies: 7
    Last Post: 09-03-2014, 07:25 AM
  3. QueryDef
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 09-18-2012, 09:31 AM
  4. Can someone explain querydef?
    By roguex20 in forum Access
    Replies: 2
    Last Post: 07-22-2012, 11:57 AM
  5. Run Time Error 3265
    By duckie10 in forum Access
    Replies: 5
    Last Post: 05-13-2009, 09:27 AM

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