Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help Populating Unbound Text Boxe Controls? (a2k (9.0.6926) SP-3 Jet 4.0 S

    I want to populate a form with two unbound Text Box Controls OrderDateTop and OrderDateNext for customer VINET

    There could be none, 1, 2 or many order records for a customer

    OrderDateTop would contain the highest order date if there is one, or

  2. #2
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help Populating Unbound Text Boxe Controls? (a2k (9.0.6926) SP-3 Jet 4

    Perfect

    for others change 'WHERE to "WHERE

    'WHERE CustomerID='VINET' ORDER BY OrderDate DESC"

    Thanks for your help

    John

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

    Re: Help Populating Unbound Text Boxe Controls? (a2k (9.0.6926) SP-3 Jet 4

    Thanks, I will correct my previous reply (it was air code).

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

    Re: Help Populating Unbound Text Boxe Controls? (a2k (9.0.6926) SP-3 Jet 4

    Edited by HansV to correct error - thanks to John for pointing it out

    You could do something like this:
    <code>
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSQL As String

    Set dbs = CurrentDb
    strSQL = "SELECT TOP 2 OrderDate FROM Orders " & _
    "WHERE CustomerID='VINET' ORDER BY OrderDate DESC"
    Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)

    If rst.EOF Then
    ' No records
    Me.OrderDateTop = "None"
    Me.OrderDateNext = "None"
    Else
    ' Fill first text box
    Me.OrderDateTop = rst!OrderDate
    rst.MoveNext
    If rst.EOF Then
    ' Only one record
    Me.OrderDateNext = "None"
    Else
    ' Fill second text box
    Me.OrderDateNext = rst!OrderDate
    End If
    End If

    rst.Close
    Set rst = Nothing
    Set dbs = Nothing</code>

Posting Permissions

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