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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple newbie question

Status
Not open for further replies.

RocAFella2007

Technical User
Mar 21, 2007
45
GB
Hi, I was wondering if anyone could help me out here please. I need the following coding to only open up the 1 form, for example whenever the menu button is selected it keeps opening a new form, but i only want it to open a new form the once. I know about creating a module, and having the 'friend' option, but you see i cannot use that method as i need to work with the following coding.

Dim frm2 As New Form2
frm2.MdiParent = Me
frm2.Text = "Equipment booking"
frm2.Show()

(Also on this form I have a exit button) When that button is pressed this form should be able to open up again.

The other part that i require help with is I have a form which is connected to a database, the text boxes in the form are data binded to a database. On a form i have created a button which if selected i want the form to reload, and to cancel all the changes that have been made. For example when that button is pressed i want the form to exactly appear when the form opens for the first time, if you understand.

If you could give me any suggestions I would really appreciate it.

Thanks
 
If you want to open the same form over and over, don't instantiate a new object each time.

Change you code to just be:

Form2.MdiParent = Me
Form2.Text = "Equipment booking"
Form2.Show()

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
You see i need that code as it shows information from a database, and on another form i can edit the data in the database. When i use the code I have shown above it shows the 'updated' data rather than me having to exit the program and then re enter it.
 
From your last reply, I presume that your data retrieval happens when form2 is loaded / created. You could move the data retrieval to the change of visibility event on form2, or even call the code from form1 using form2.retrievedata for example.

That way the code suggested by mstrmage1768 would work for you.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top