|
-
Aug 21st, 2000, 10:22 AM
#1
Thread Starter
Junior Member
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?
-
Aug 21st, 2000, 11:33 AM
#2
Lively Member
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
-
Aug 21st, 2000, 12:22 PM
#3
Thread Starter
Junior Member
Hi Dr_Evil
I am trying to use ADO Find
-
Aug 22nd, 2000, 12:03 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|