Solved

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

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

773 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