+ Reply to Thread
Results 1 to 3 of 3

On error resume next and cdate problem

  1. #1

    On error resume next and cdate problem

    Hello,
    I'm having a problem with the code stopping at the (Range("Bid_Date") =
    CDate(TextBox5)) line. My code was working fine until I added the lines
    for the description check which makes sure the user doesn't add a
    description in the textbox of the userform that has been previously
    entered. I think the problem may be with the error goto & error resume
    next statement. Does anybody have any insight on this?
    Thanks,
    Darrell


    'CHECKS IF DESCRIPTION HAS BEEN PREVIOUSLY ENTERED
    '...Added description check

    On Error GoTo 100
    If Cells.Find(What:=i, After:=ActiveCell, LookIn:=xlFormulas,
    LookAt _
    :=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=ylNext,
    MatchCase:= _
    True).Activate = True Then
    MsgBox "The description you entered has been entered on a previous
    job."
    GoTo 200
    End If

    100

    Range("L3").Select
    Cells.Find(What:=n, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByColumns, SearchDirection:=ylNext,
    MatchCase:= _
    False).Activate


    Selection.Offset(0, -10).Select



    response = MsgBox("Do you want to add this information to another line
    for existing job# " & j & "-" & Format(k, "000") & "?", vbYesNo)
    If response = vbYes Then

    Unload Existing_Task

    Range("EII_Number") = CInt(TextBox1)
    Range("Seq_Number") = CInt(TextBox2)
    Range("Customer") = TextBox3
    Range("Solicitation") = TextBox4

    On Error Resume Next
    MsgBox Existing_Task.TextBox5
    '...Stops at the following line
    Range("Bid_Date") = CDate(TextBox5)
    If CDate(TextBox5) = False Then
    Range("Bid_Date") = TextBox5
    End If


  2. #2
    Tom Ogilvy
    Guest

    Re: On error resume next and cdate problem

    if your find statment does not find a duplicate entry, then it will try to
    activate nothing. That will raise an error.

    Dim rng as Range
    set rng = Cells.Find()
    if not rng is nothing then
    rng.activate
    msgbox "something"
    else
    ' no duplicate found
    End if

    --
    Regards,
    Tom Ogilvy


    <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    > I'm having a problem with the code stopping at the (Range("Bid_Date") =
    > CDate(TextBox5)) line. My code was working fine until I added the lines
    > for the description check which makes sure the user doesn't add a
    > description in the textbox of the userform that has been previously
    > entered. I think the problem may be with the error goto & error resume
    > next statement. Does anybody have any insight on this?
    > Thanks,
    > Darrell
    >
    >
    > 'CHECKS IF DESCRIPTION HAS BEEN PREVIOUSLY ENTERED
    > '...Added description check
    >
    > On Error GoTo 100
    > If Cells.Find(What:=i, After:=ActiveCell, LookIn:=xlFormulas,
    > LookAt _
    > :=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=ylNext,
    > MatchCase:= _
    > True).Activate = True Then
    > MsgBox "The description you entered has been entered on a previous
    > job."
    > GoTo 200
    > End If
    >
    > 100
    >
    > Range("L3").Select
    > Cells.Find(What:=n, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    > :=xlPart, SearchOrder:=xlByColumns, SearchDirection:=ylNext,
    > MatchCase:= _
    > False).Activate
    >
    >
    > Selection.Offset(0, -10).Select
    >
    >
    >
    > response = MsgBox("Do you want to add this information to another line
    > for existing job# " & j & "-" & Format(k, "000") & "?", vbYesNo)
    > If response = vbYes Then
    >
    > Unload Existing_Task
    >
    > Range("EII_Number") = CInt(TextBox1)
    > Range("Seq_Number") = CInt(TextBox2)
    > Range("Customer") = TextBox3
    > Range("Solicitation") = TextBox4
    >
    > On Error Resume Next
    > MsgBox Existing_Task.TextBox5
    > '...Stops at the following line
    > Range("Bid_Date") = CDate(TextBox5)
    > If CDate(TextBox5) = False Then
    > Range("Bid_Date") = TextBox5
    > End If
    >




  3. #3

    Re: On error resume next and cdate problem

    I appreciate it Tom. That fixed it.
    Thanks,
    Darrell


+ 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