Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA query (Win XP Access 2007)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBA query (Win XP Access 2007)

    To indicate a field of the recordset instead of a property, use an exclamation mark. Try
    <code>
    Debug.Print !Quantity</code>

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA query (Win XP Access 2007)

    Thank you. As usual, right on.

Posting Permissions

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