Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public Sub New - Stop Form Load

Status
Not open for further replies.

itflash

Programmer
Jul 18, 2001
535
GB
Hi All

I have a form that is called by the following code:

Dim frm2 As New frm_form1(param1, param2)
frm2.ShowDialog()

In the "Public Sub New" event of the form, I need to check a value and if this matches, close the form.

So I do...

msgBox("You cannot alter this record")
dispose() ' tried me.close()

after the initialize component.

However, this gives an error in the calling form saying frm_form1 does not exist.

What is the best way of doing this?
I basically want to be able to close my form on startup if a condition is met (without showing it).


Thanks
ITflash

 


suppose I could put a try/catch/ around the frm2.ShowDialog()

 
itflash,

I'm confused about the order you are trying to accomplish. Do you not want frm2 to load?

phan
 
Why dont you just check before you load

Dim frm2 As New frm_form1()
'Use a function from this form to see if values match

If match Then
frm2.ShowDialog()
Else
frm2.Dispose
End IF


DotNetDoc
M.C.S.D.
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein





 



Thanks for the replies.

The reason I was doing this is because on the form 2 load, I have datasets loaded that checked a value. Didnt want to create an additional data set in form 1 when form 2 has it already.

So basically, form 2 loads, checks a value and cancels the load if a value matches something instead of form 1 checking the value.





Thanks
ITflash



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top