Strange Data Parameter Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob

    #1

    Strange Data Parameter Problem

    Hello:

    Ok I have two code samples here. This one doesn't work at all.

    The error is
    Input string was not in a correct format.


    daClientsMain.S electCommand.Pa rameters("Clien tID").Value
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("Offic eFileNum").Valu e
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("MortP olNum").Value
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("FeePo lNum").Value
    = txtFind.Text

    Dim MyCheck As Boolean
    MyCheck = IsDate(txtFind. Text)
    If MyCheck = True Then
    daClientsMain.S electCommand.Pa rameters("Closi ngDate").Value
    = CDate(txtFind.T ext)
    Else
    daClientsMain.S electCommand.Pa rameters("Closi ngDate").Value
    = CDate(#2/2/1902#)
    End If

    daClientsMain.S electCommand.Pa rameters("Buyer SearchCode").Va lue
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("Selle rSearchCode").V alue
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("Prope rtyAddress").Va lue
    = txtFind.Text
    Me.daClientsMai n.Fill(objdsCli ents)


    But this one does work as long as I type in a valide date into txtFind.Text:



    daClientsMain.S electCommand.Pa rameters("Clien tID").Value
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("Offic eFileNum").Valu e
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("MortP olNum").Value
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("FeePo lNum").Value
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("Closi ngDate").Value
    = CDate(txtFind.T ext)
    daClientsMain.S electCommand.Pa rameters("Buyer SearchCode").Va lue
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("Selle rSearchCode").V alue
    = txtFind.Text
    daClientsMain.S electCommand.Pa rameters("Prope rtyAddress").Va lue
    = txtFind.Text
    Me.daClientsMai n.Fill(objdsCli ents)


    I can type in any date format into it and it works ie 5/5/05 or 5/5/2005 or
    05/05/05 or 05/05/2005 or May 5, 2005 all work in the second sample..


    TIA

    Bob


  • The Whistler

    #2
    Re: Strange Data Parameter Problem

    Does it work if you change the
    CDate(#2/2/1902#)
    to
    CDate("2/2/1902")
    ?



    On Wed, 20 Jul 2005 21:18:43 GMT, "Bob" <nojunk@nospamm ers.com> wrote:
    [color=blue]
    >Hello:
    >
    >Ok I have two code samples here. This one doesn't work at all.
    >
    >The error is
    >Input string was not in a correct format.
    >
    >
    > daClientsMain.S electCommand.Pa rameters("Clien tID").Value
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("Offic eFileNum").Valu e
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("MortP olNum").Value
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("FeePo lNum").Value
    >= txtFind.Text
    >
    > Dim MyCheck As Boolean
    > MyCheck = IsDate(txtFind. Text)
    > If MyCheck = True Then
    > daClientsMain.S electCommand.Pa rameters("Closi ngDate").Value
    >= CDate(txtFind.T ext)
    > Else
    > daClientsMain.S electCommand.Pa rameters("Closi ngDate").Value
    >= CDate(#2/2/1902#)
    > End If
    >
    > daClientsMain.S electCommand.Pa rameters("Buyer SearchCode").Va lue
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("Selle rSearchCode").V alue
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("Prope rtyAddress").Va lue
    >= txtFind.Text
    > Me.daClientsMai n.Fill(objdsCli ents)
    >
    >
    >But this one does work as long as I type in a valide date into txtFind.Text:
    >
    >
    >
    > daClientsMain.S electCommand.Pa rameters("Clien tID").Value
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("Offic eFileNum").Valu e
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("MortP olNum").Value
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("FeePo lNum").Value
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("Closi ngDate").Value
    >= CDate(txtFind.T ext)
    > daClientsMain.S electCommand.Pa rameters("Buyer SearchCode").Va lue
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("Selle rSearchCode").V alue
    >= txtFind.Text
    > daClientsMain.S electCommand.Pa rameters("Prope rtyAddress").Va lue
    >= txtFind.Text
    > Me.daClientsMai n.Fill(objdsCli ents)
    >
    >
    >I can type in any date format into it and it works ie 5/5/05 or 5/5/2005 or
    >05/05/05 or 05/05/2005 or May 5, 2005 all work in the second sample..
    >
    >
    >TIA
    >
    >Bob
    >[/color]

    Comment

    • Bob

      #3
      Re: Strange Data Parameter Problem

      no but it works if I change

      daClientsMain.S electCommand.Pa rameters("Clien tID").Value = txtFind.Text

      to

      daClientsMain.S electCommand.Pa rameters("Clien tID").Value = 0

      but not if I change it to

      daClientsMain.S electCommand.Pa rameters("Clien tID").Value =
      CInt(txtFind.Te xt)

      I see I need to write some err handling

      Bob


      Comment

      Working...