×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Don't want to reload question

Don't want to reload question

Don't want to reload question

(OP)
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.


RE: Don't want to reload question

Quote (Igawa29 )

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.

RE: Don't want to reload question

(OP)
Good idea! I didn't think of that. Having the save button disabled until fields are filled out. That is perfect, thank you!

RE: Don't want to reload question

I am glad you like it. smile

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close