Solved

Creating a lookup form for data

Posted on 2004-09-23
6
295 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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