+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18

Thread: Type mismatch in date field.

  1. #16
    Valued Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Type mismatch in date field.

    I have tried the following corrections:

    Private Sub btnOK_Click()
    
        'OK button, escribo los valores en OPT DATA
        ValidClose = True
        Select Case ClType
            Case FUTURE, NOBID
                If Len(Me.FollowupDate.Text) = 0 Or Not IsDate(Me.FollowupDate.Text) Then
                    ValidClose = False
                    MsgBox "You must set a follow up date for this type of Close Action"
                End If
    
        End Select
        
        If ValidClose Then
            Application.ScreenUpdating = False
            rs!Status = ClType
            rs!Reason = Me.Reason.Text
            If Me.FollowupDate.Text <> "" Then
                rs!FollowupDate = CDate(Me.FollowupDate.Text) <-------- error
            Else
                rs!FollowupDate = Null
            End If
            
            Unload Me
        End If
    End Sub
    also,

    Private Sub btnOK_Click()
    
    If IsNumeric(Me.Followupdate.Value) Then
        ValidClose = True
        Select Case ClType
            Case FUTURE, NOBID
                If Len(Me.Followupdate.Text) = 0 Then
                    ValidClose = False
                    MsgBox "You must set a followup date for this type of Close Action"
                End If
        End Select
        If ValidClose Then
            Application.ScreenUpdating = False
            rs!Status = ClType
            rs!Reason = Me.Reason.Text
            If Me.Followupdate.Text <> "" Then
                rs!Followupdate = CDate(Me.Followupdate.Text) < -------Error
            Else
                rs!Followupdate = Null
            End If
            
            Unload Me
        End If
    Else
        MsgBox "Only numbers are allowed in the Followup Date Field." & vbLf & _
               "Please try again"
        Me.Followupdate.SetFocus
        Me.Followupdate = ""
    End If
    
    End Sub
    and last,

    Private Sub btnOK_Click()
    
    If IsNumeric(Me.Followupdate.Value) Then
        ValidClose = True
        Select Case ClType
            Case FUTURE, NOBID
                If Len(Me.Followupdate.Text) > 0 Then
                    ValidClose = False
                    MsgBox "You must set a followup date for this type of Close Action"
                End If
        End Select
        If ValidClose Then
            Application.ScreenUpdating = False
            rs!Status = ClType
            rs!Reason = Me.Reason.Text
            If Me.Followupdate.Text <> "" Then
                rs!Followupdate = CDate(Me.Followupdate.Text) <------ Error
            Else
                rs!Followupdate = Null
            End If
            
            Unload Me
        End If
    Else
        MsgBox "Only numbers are allowed in the Followup Date Field." & vbLf & _
               "Please try again"
        Me.Followupdate.SetFocus
        Me.Followupdate = ""
    End If
    
    End Sub

  2. #17
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Type mismatch in date field.

    The test for length and IsDate should NOT be inside a Select Case statement.

  3. #18
    Valued Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Type mismatch in date field.

    Thanks I got it. I can be dense some time.

    Private Sub btnOK_Click()
    
        'OK button, escribo los valores en OPT DATA
        ValidClose = True
        Select Case ClType
            Case FUTURE, NOBID
        End Select
        
        If Len(Me.FollowupDate.Text) = 0 Or Not IsDate(Me.FollowupDate.Text) Then
            ValidClose = False
            MsgBox "You must set a follow up date for this type of Close Action"
        End If
        
        If ValidClose Then
            Application.ScreenUpdating = False
            rs!Status = ClType
            rs!Reason = Me.Reason.Text
            If Me.FollowupDate.Text <> "" Then
                rs!FollowupDate = CDate(Me.FollowupDate.Text)
            Else
                rs!FollowupDate = Null
            End If
            
            Unload Me
        End If
    End Sub

+ 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.2.0