Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vb6 List Box Double-Click Problem

Posted on 2014-01-03
4
Medium Priority
?
414 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
[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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
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 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…
Suggested Courses

636 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