Solved

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

Posted on 2004-08-16
5
253 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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month7 days, 5 hours left to enroll

622 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