Solved

Creating a lookup form for data

Posted on 2004-09-23
6
290 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
Technology Partners: 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Modal Popup Extender control 1 51
VB.Net WebRequest Code from JSON curl 7 86
vb.net Configuration, settings file location? 8 42
Data organization issue 7 36
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 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