• VBA query (Win XP Access 2007)

    Author
    Topic
    #445135

    This procedure correctly prints the record count. If I change the Debug.print .recordcount to Debug.print .quantity, I do not get the quantity, but an error. How do I get the content of the quantity field to print?

    Private Sub Command0_Click()

    Dim db As Database
    Dim strSQL As String
    Dim qdfTemp As QueryDef
    Dim rst As Recordset

    Set db = CurrentDb
    strSQL = “SELECT * FROM [Order Details]”
    Set qdfTemp = db.CreateQueryDef(“”, strSQL)
    Set rst = qdfTemp.OpenRecordset(dbOpenDynaset)

    With rst
    .MoveLast
    Debug.Print .RecordCount
    .Close
    End With

    End Sub

    Viewing 1 reply thread
    Author
    Replies
    • #1078487

      To indicate a field of the recordset instead of a property, use an exclamation mark. Try

      Debug.Print !Quantity

    • #1078492

      Thank you. As usual, right on.

    Viewing 1 reply thread
    Reply To: VBA query (Win XP Access 2007)

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

    Your information: