Solved

Creating a lookup form for data

Posted on 2004-09-23
6
268 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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 …
A short film showing how OnPage and Connectwise integration works.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

13 Experts available now in Live!

Get 1:1 Help Now