Solved

Creating a lookup form for data

Posted on 2004-09-23
6
256 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

16 Experts available now in Live!

Get 1:1 Help Now