Solved

How to put correspondance entry in textbox from field1 according to dbcombo containing entry from field2.

Posted on 2004-08-16
5
252 Views
Last Modified: 2010-05-02
I am using Visual Basic 6. I have a database created using built in data manager and it contains one table and two fields who have more than 50 entries. I am using one dbcombo to select an entry from feild1.
My question is I want to display the CORRESPONDING entry of FIELD2 in a text box i.e.  changing the selection in dbcombo(containing entry from field1) leads to correspondance change in textbox who will contain entry from field2. How can i do so...please provide code...Thanx
0
Comment
Question by:omyurs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 19

Accepted Solution

by:
Shauli earned 75 total points
ID: 11819380
Change yourfield1, yourfield2 and yourtable to the corresponding field names and table name. If field1 is of numeric type then you'll have to remove the singlequotes (') from the sql statement. myConn is the connection and myRS is the recordset, rename it accordingly.

Private Sub Combo1_Click()
myRS.CursorLocation = adUseClient
myRS.Open "SELECT yourfield2 FROM yourtable WHERE yourfield1='" & Combo1.Text & "';", myConn, adOpenKeyset, adLockReadOnly
    With myRS
        If Not .EOF Then
            Text1.Text = !yourfield2
        Else
            MsgBox "Can't find corresponding field"
        End If
    End With
myRS.Close
End Sub

S
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question