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

Don't want to reload question 1

Status
Not open for further replies.

Igawa29

MIS
Jan 28, 2010
99
US
So I have a load action that automatically refreshes the page during a successful save (via the Save_Button.Click)

Code:
Private Sub Main_Add_Load(sender As Object, e As EventArgs) Handles MyBase.Load, Save_Button.Click

The issue is that when the user clicks the save button I need to check to make sure a certain field was populated. When this happens and I exit the sub, the page refreshes and removes all of the users selections. I want to still have my check put in, but I want to abandon the user save button click if possible.

Code:
        If PosType_CB.Text = "" Then
            MsgBox("You Must Select a User Type", MsgBoxStyle.Exclamation, "Select a User Type")
            Exit Sub
        End If

I am thinking there is something else I can put in other than the Exit Sub. Something that will not cause the Load to occur again, but I am stumped.


 
Igawa29 said:
when the user clicks the save button I need to check to make sure a certain field was populated

I usually do it the other way around: I check to make sure all needed fields are populated/selected before user can click on the save button. I do indicate on the form which fields are required.


---- Andy

There is a great need for a sarcasm font.
 
Good idea! I didn't think of that. Having the save button disabled until fields are filled out. That is perfect, thank you!
 
I am glad you like it. :)

What I usually do, I create a Sub (which I call from different controls' change event, or whatever) where I check if there is all that I need. If I need 3 pieces of info, I do something like:

Code:
Private Sub SomeMagic()

btnSave.Enable = Len(Trim(PosType_CB.Text)) * Len(Trim(FirstTxt.Text)) * 
Len(Trim(LastTxt.Text)) 

End Sub

It is a VB6 syntax, but you get the idea.


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top