Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

vb6 List Box Double-Click Problem

Posted on 2014-01-03
4
Medium Priority
?
415 Views
Last Modified: 2014-01-03
Here is a problem for the old sages...I have a vb6 app that I am upgrading.  It has a list box with a list of data of varying number.  It is basically a list of participants in a race with their first name, last name, gender, etc.  What I want to do is be able to double-click on that list and have the data edit form come up as a modal form with that person's data populating the fields on that form.

Currently you have to open the edit form, find their unique ID in a drop down and click on that to get their data to populate.  I want to make the process quicker and easier.

Thanks a ton.  Best site ever for helping hacks like me...
0
Comment
Question by:Bob Schneider
  • 2
  • 2
4 Comments
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 2000 total points
ID: 39753919
It's not clear what your exact situation is, if you are using a database, whether any database is accessed using ADO or DAO, and whether the controls are bound or not.

Here is some very simple code that used an arbitrary function to populate one of two text boxes on the called Form

Option Explicit

Private Sub Form_Load()
List1.AddItem "One"
List1.AddItem "Two"
List1.AddItem "Three"
List1.AddItem "Four"
List1.AddItem "Five"

End Sub

Private Sub List1_DblClick()
Form2.Text1.Text = List1.Text
Form2.Show vbModal
End Sub

Open in new window


Option Explicit

Private Sub Form_Activate()
    Text2.Text = GetField2(Text1.Text)
End Sub

Function GetField2(strText As String) As String
    GetField2 = strText & "2"
End Function

Open in new window

0
 

Author Comment

by:Bob Schneider
ID: 39753931
Yes I am using sql server 2008 but the only things I am not clear on is:

1) How to get the frmEditData to open when double clicking an item in the list of the frmPartic form, and

2) How to pass the unique id of the record that was selected via double-click on the frmPartic form to the frmEditData form so that it can populate the necessary fields.

Sorry I was not more complete initially.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 39754036
The sample code above shows how to open the second form with a double-click.

You can get the value by

a) In Form2 you can read it from Form1:
   Form1.List1.text

b) Set a variable of form2

Dim MyFieldValue  as string
 Private Sub List1_DblClick()
     Form2.MyFieldValue = List1.Text
    Form2.Show vbModal
End Sub

c) as in the original example, you can set the value of a Text box control

d) Use a global variable (not recommended)
0
 

Author Closing Comment

by:Bob Schneider
ID: 39754170
Awesome!  Thank you!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

810 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