Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

VBA Multipage

Status
Not open for further replies.

athomas236

Mechanical
Jul 1, 2002
607
I am writing an application in which I am using a multipage that has two pages. One page is used to enter saturated steam conditions and one to enter superheated steam/subcooled water conditions. All data is entered via text boxes.

What I want to do is the following:

1. When I show the userform, I want to set all text box values on the multipage to empty.

2. When either page of the multipage is selected, set the text boxes on the non selected page to empty.

3. For the selected page, check that data has been entered and ignore the fact that the text boxes on the non selected page are empty.

Any advice/guidance will be appreciated.

athomas236
 
Replies continue below

Recommended for you

Sorry cowski,

Looked at the website you suggested but could not see how it would help.

best regards,

athomas236
 
What exactly are you trying to do? Especially your step 3. What do you want to trigger this action? A button? When any text box is updated? If you want to ignore certain boxes just don't include them in your code. You'll probably want to do separate routines for each page of your multipage.

cowski's link is to code that will give you access to each control on your form without having to specify it by name. This will help you on step 1. You'll just have to check what type of control it is and, if it's a text box, set it's .text property to "". Check the msForms help for properies/methods of the Control object. There should be a .type property or something that will tell you if the control is a text box or not.
 
The link I posted would help you with your question 1 & 2. When you show your form simply loop through the textboxes and set them all to "". When you select a page an event is fired, on that event loop through the textboxes on the opposite page and set them to "".

You might want to rethink #2. Personally, as a user I would be pretty upset if all my input data was erased simply by switching pages. Maybe put a control button on each sheet to process the information on each sheet separately.

For #3, you don't have to 'actively ignore' any input. It is up to you to write code to validate and process the input. If you want to ignore certain input then you simply don't write code for it.
 
Gentlemen,

1. This is the code I use for entering data through a textbox and to check if the box is empty and valid.

Private Sub CommandButton1_Click()

' This is standard code to accept input through text box
' Validate the input
If Not IsNumeric(TextBox4) Then
MsgBox "Invalid or missing saturated steam data."
Exit Sub
End If

' This is standard code for changing input from text box
' into a number
a = Val(TextBox4.Text)
MsgBox "Input = " & a

End Sub

2. On the first page of the multipage the input is either pressure or temperature so I can calculate the conditions on the saturated steam line and on the second page is pressure and temperature so I can calculate steam conditions off the saturation line. I just want the values on the unselected page to be blank.

Best regards,

athomas236
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor