Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Share codes 68 115
change vba from autofit to 13.5 width? 4 27
Add a task in Outlook from access 11 32
VB6 - Convert HH:MM into Decimal 8 38
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now