Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

831 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