Solved

Creating a lookup form for data

Posted on 2004-09-23
6
293 Views
Last Modified: 2012-05-05
Here's what I'm trying to do:

Form1:
Has bound controls showing 1 record at a time. Has a quick find button.  When the user hit this I want another form to pop-up (Dialog - Form2)  

Form 2:
Show a list box or grid with all records, a text box, and a combo box with all fields, ok and cancel buttons.
The user can search and select one record.  When they click OK, then Form 1 will move to the record the user selected.

I have to be able to do with with many tables, so I figured I'll pass a dataview to the form, but I don't quite understand how I could pass the id of the selected record back to form 1.  Once I have the id, I know how I can find the position in my current dataset.  It's just being able to get the id, and being able to use it when form2 closes and run my sub to move to the position.  

Please help :)

Tigger
0
Comment
Question by:Tigger996
[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
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:Excalibur_Software
ID: 12136673
One way is the change the scope to global on a variable in one of your module
now when your form1 is load clear the variable when the user clicks the button to go to your form2 you load that variable with the information you need. on the close event on form2 you load that same variable with the information you need for form1
It is that easy.
0
 
LVL 7

Accepted Solution

by:
natloz earned 500 total points
ID: 12136722
This is how I normally would do it...

create a module called modGlobal

Module modGlobal
    Public _intPOID As Integer = 0 'ID of PO for Detail
End Module


Form 1 Code...
Dim frmPO As frmPO = New frmPO
frmPO.ShowDialog()
if _intPOID = 0 then
   'Nothing was selected from form (Cancelled)
else
   'DO YOUR FILTER ON DATASET
endif

Form 2 Code...
btnSubmit_Click(blah)
  _intPOID = intSelectionID

btnCancel_Click(blah)
   _intPOID = 0
0
 

Author Comment

by:Tigger996
ID: 12136750
natioz,

I think I understand what you are doing, but wouldn't I need to raise an event or something in form1 so that form1 knows that the user has selected (or not selected) a record so that I can run a sub to move to that record?

Tigger
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:natloz
ID: 12136790
Basically it works like this...you should have a submit button or something on the Form2 once the user has finalized their selection....either that or on a Click event...

When you show a form as "frmPO.ShowDialog()" your a showing a MODAL form that the user cannot leave or come back to Form1 until the form has been closed...which YOU CONTROL...once Form2 has been closed...the code returns to Form1 where it left off....and runs any code following the ShowDialog....

Do a test with

Dim Form2 as form2 = new form2
form2.showdialog
msgBox("Back at form1 cause form2 has been closed")
0
 

Author Comment

by:Tigger996
ID: 12136802
oh ok, I didn't know that.  I will try it out.
0
 

Author Comment

by:Tigger996
ID: 12139375
Works Great.  Thanks!
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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

732 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