• Variable Append Query (2003)

    Author
    Topic
    #398106

    I expect that this is easy if you know what you

    Viewing 1 reply thread
    Author
    Replies
    • #758680

      If you create a parameter query, and declare the parameter explicitly in Query | Parameters…, you can use DAO to set the parameter in code. You need to set a reference to the Microsoft DAO 3.6 Object Library in Tools | Options… in the Visual Basic Editor. Code could look like the following, with the appropriate names substituted.

      Sub RunAppend(strNotes As String)
      Dim dbs As DAO.Database
      Dim qdf As DAO.QueryDef

      Set dbs = CurrentDb
      ‘ use name of your query for MyAppendQuery
      Set qdf = dbs.QueryDefs(“MyAppendQuery”)

      ‘ use name of your parameter for Enter NoteText
      qdf.Parameters(“Enter NoteText”) = strNotes
      qdf.Execute

      Set qdf = Nothing
      Set dbs = Nothing
      End Sub

      Sub AppendMultiple()
      ‘ call RunAppend as many times as needed
      RunAppend “Letter Sent”
      RunAppend “Letter Received”
      RunAppend “Letter Torn”
      RunAppend “Letter Eaten”
      End Sub

      • #758740

        Thanks Hans. I’ve played with the code but lack the experience/knowledge to make it work.

        • #758748

          If you want to pursue this, please indicate where you get stuck, or where things go wrong. We will try to help you get it right.

          • #759667

            Thanks for your help but I chickened out & did it with a clutch of individual append queries

          • #759668

            Thanks for your help but I chickened out & did it with a clutch of individual append queries

        • #758749

          If you want to pursue this, please indicate where you get stuck, or where things go wrong. We will try to help you get it right.

      • #758741

        Thanks Hans. I’ve played with the code but lack the experience/knowledge to make it work.

    • #758681

      If you create a parameter query, and declare the parameter explicitly in Query | Parameters…, you can use DAO to set the parameter in code. You need to set a reference to the Microsoft DAO 3.6 Object Library in Tools | Options… in the Visual Basic Editor. Code could look like the following, with the appropriate names substituted.

      Sub RunAppend(strNotes As String)
      Dim dbs As DAO.Database
      Dim qdf As DAO.QueryDef

      Set dbs = CurrentDb
      ‘ use name of your query for MyAppendQuery
      Set qdf = dbs.QueryDefs(“MyAppendQuery”)

      ‘ use name of your parameter for Enter NoteText
      qdf.Parameters(“Enter NoteText”) = strNotes
      qdf.Execute

      Set qdf = Nothing
      Set dbs = Nothing
      End Sub

      Sub AppendMultiple()
      ‘ call RunAppend as many times as needed
      RunAppend “Letter Sent”
      RunAppend “Letter Received”
      RunAppend “Letter Torn”
      RunAppend “Letter Eaten”
      End Sub

    Viewing 1 reply thread
    Reply To: Variable Append Query (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: