+ Reply to Thread
Results 1 to 2 of 2

CheckDate and return to usrfrm

  1. #1
    Fabrizio
    Guest

    CheckDate and return to usrfrm

    I have a problem with a userform. This userform is shown when the user clicks
    on a button in the excel spreadsheet. The user is then to enter some info in
    various fields in the userForm. However when the user submits erronous info
    the program gives a message in a message box to the user. when the user
    clicks the ok button the user shall return to the userform (preferably
    containing the same info as before). My problem is that I dont know how to
    retun to the userform. In the code for Sheet1 I have:

    Public Sub startKnapp_Click()
    userForm1.Show
    End Sub

    when the user clicks the button the userform is shown and it is possible to
    enter info. The check for error info (it works) is:

    Private Sub checkDate()
    If (Not (IsDate(userForm1.TextBox1.Text))) Then
    MsgBox ("Error")
    End If
    If (Not (IsDate(userForm1.TextBox2.Text))) Then
    MsgBox ("Error")
    End If
    End Sub

    however this sub is called when the user has enterd info and THEN PRESSES AN
    OK BUTTON. The code is:

    Private Sub genereraRapportKnapp_Click()
    Call checkDate
    Call mainProgram
    Unload Me
    End Sub

    How do I write the code so that the user returns to the form? I have tried
    calling the sub that shows the userform but it does not work (the program
    says that it is already shown..). If you know how to solve this problem or
    avoid it please help me! Any assistance is of value! Someone said that you
    could use the EXIT for the textboxes to check dateformat but this turns out
    to quite messy in my case. What I want to do is to have the sub

    genereraRapportKnapp_Click

    and let this sub call another sub that returns a (boolean) value that says
    if there are any problems. If there are then exit sub i.e. exit the
    genereraRapportKnapp_Click

    I think this will work but I do not know how to fix it. Please please help
    me!!!


  2. #2
    Bob Phillips
    Guest

    Re: CheckDate and return to usrfrm

    Where are all the procedures stored, in the userform or a code module? It
    seems the form is open when you try and re-open, so exiting the sub might be
    enough.

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Fabrizio" <Fabrizio@discussions.microsoft.com> wrote in message
    news:AD503F8E-4079-4B8D-AD95-992412644FFD@microsoft.com...
    > I have a problem with a userform. This userform is shown when the user

    clicks
    > on a button in the excel spreadsheet. The user is then to enter some info

    in
    > various fields in the userForm. However when the user submits erronous

    info
    > the program gives a message in a message box to the user. when the user
    > clicks the ok button the user shall return to the userform (preferably
    > containing the same info as before). My problem is that I dont know how to
    > retun to the userform. In the code for Sheet1 I have:
    >
    > Public Sub startKnapp_Click()
    > userForm1.Show
    > End Sub
    >
    > when the user clicks the button the userform is shown and it is possible

    to
    > enter info. The check for error info (it works) is:
    >
    > Private Sub checkDate()
    > If (Not (IsDate(userForm1.TextBox1.Text))) Then
    > MsgBox ("Error")
    > End If
    > If (Not (IsDate(userForm1.TextBox2.Text))) Then
    > MsgBox ("Error")
    > End If
    > End Sub
    >
    > however this sub is called when the user has enterd info and THEN PRESSES

    AN
    > OK BUTTON. The code is:
    >
    > Private Sub genereraRapportKnapp_Click()
    > Call checkDate
    > Call mainProgram
    > Unload Me
    > End Sub
    >
    > How do I write the code so that the user returns to the form? I have tried
    > calling the sub that shows the userform but it does not work (the program
    > says that it is already shown..). If you know how to solve this problem or
    > avoid it please help me! Any assistance is of value! Someone said that you
    > could use the EXIT for the textboxes to check dateformat but this turns

    out
    > to quite messy in my case. What I want to do is to have the sub
    >
    > genereraRapportKnapp_Click
    >
    > and let this sub call another sub that returns a (boolean) value that says
    > if there are any problems. If there are then exit sub i.e. exit the
    > genereraRapportKnapp_Click
    >
    > I think this will work but I do not know how to fix it. Please please help
    > me!!!
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1