Results 1 to 4 of 4

Thread: Accessing two fields from same table

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    23

    Question

    I would like to access two fields from the same table. When the user chooses a client from the data ComboBox then the ClientID text box should populate with the corresponding ID.
    How do I do this?

  2. #2
    Lively Member Dr_Evil's Avatar
    Join Date
    Mar 2000
    Location
    Columbus, OH
    Posts
    105
    You could use SQL to poulate your TextBox with the corresponding ClientID. Try using something like this. If you need me to ellaborate more let me know.

    Code:
    Dim cnn As Connection
    Dim rs As Recordset
    
    Set cnn = New Connection
    Set rs = New Recordset
    
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                    "Data Source=C:\\yourDB.mdb;"
    
    rs.Open "SELECT `ClientID` FROM `TableName` WHERE `client` = '" & cboClient.Text & "' ", cnn, adOpenStatic, adLockReadOnly
    
    Set txtClientID.DataSource = rs
    txtClientID.DataField = "ClientID" 'The field name from table.
    
    rs.Close
    cnn.Close
    Set rs = Nothing
    Dr_Evil
    Senior Programmer
    VS6 EE
    VS.NET EA

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    23
    Hi Dr_Evil
    I am trying to use ADO Find

  4. #4
    Guest
    Find does not support multiple column comparison. An alternative is to use the filter method(if you need to match rows based on 2 or more fields).

    Here's how to use it:

    rs.filter = "column1 = 'ABC' and column2 = 1"
    if rs.eof then
    msgbox "no matching rows"
    else
    msgbox rs!column3
    end if

    to reset,

    rs.filter = ""

Posting Permissions

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



Click Here to Expand Forum to Full Width