Results 1 to 7 of 7
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    controll date in entry textbox... (2000 sr 1)

    in the 2 textboxes (1 and 2) is possible to insert a controll if a date inserted is not regualr...

    for example appear msgbox if i insert 31/11/2006, 30/02/2006, 31/04/2005 ecc...

  2. #2
    2 Star Lounger
    Join Date
    Mar 2004
    Location
    Cincinnati, Ohio, USA
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: controll date in entry textbox... (2000 sr 1)

    I would suggest that you review the IsDate() function.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: controll date in entry textbox... (2000 sr 1)

    As Mike indicates (you haven't let him know whether his reply was helpful), you can use IsDate: you could add a line

    If Not IsDate(Me.TextBox1) Then GoTo DATAERRATA

    in the TextBox1_AfterUpdate procedure, and similar for TextBox2.

  4. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: controll date in entry textbox... (2000 sr 1)

    Hi my Great friend, i am here with a prob on setfocus...
    Why when the date is wrong the cursor no return in textbox1???

    ... and tell me if the structure of code is correct to controll the coorect entry oof dates.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: controll date in entry textbox... (2000 sr 1)

    In which procedure?

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: controll date in entry textbox... (2000 sr 1)

    textbox1 aftrerupdate
    textbox2 aftrerupdate
    command_button1_click

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: controll date in entry textbox... (2000 sr 1)

    I don't see any code to test whether dates are correct in CommandButton1_Click.

    For the text boxes, you should use the BeforeUpdate event instead of the AfterUpdate event, and set the Cancel argument to True if the date is incorrect:

    Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    If Me.TextBox1 = "" Then
    MsgBox ("Questo campo non puo' essere vuoto"), vbCritical
    Cancel = True
    Exit Sub
    End If

    If Not IsDate(Me.TextBox1) Then
    MsgBox "Inserire la data nel formato gg/mm/aaaa", vbCritical
    Cancel = True
    Exit Sub
    End If

    DATAIN = Me.TextBox1
    End Sub

    and similar for TextBox2.

Posting Permissions

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