Editing field in filtered SQL query - RunTime Error 3464

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

    #1

    Editing field in filtered SQL query - RunTime Error 3464

    In the following code I am attempting to open a query and edit the
    lastMaintenance field for a particular equipment number. My code looks like
    this:

    Dim db As Database
    Dim rs As Recordset
    Dim SQL As String

    Set db = DBEngine.Worksp aces(0).Databas es(0)
    Set rs = db.OpenRecordse t("SELECT * From qryPlannedMaint enance WHERE
    [EquipmentNumber] = '" & EquipmentNumber & "';")
    rs.MoveFirst
    rs.Edit
    rs![LastMaintenance] = Date
    rs.Update
    rs.Close

    Set rs = Nothing
    Set db = Nothing

    At the moment I am getting this run time error on the Set rs line:
    Run-time error 3464. Data type mismatch in criteria expression.

    Any suggestions?

    Thanks in advance


  • Will

    #2
    Re: Editing field in filtered SQL query - RunTime Error 3464

    Solved
    It was the ' 's

    thanks

    "Will" <Will87212REMOV ETHIS@hotmail.c om> wrote in message
    news:39oeo0F658 k79U1@individua l.net...[color=blue]
    > In the following code I am attempting to open a query and edit the
    > lastMaintenance field for a particular equipment number. My code looks[/color]
    like[color=blue]
    > this:
    >
    > Dim db As Database
    > Dim rs As Recordset
    > Dim SQL As String
    >
    > Set db = DBEngine.Worksp aces(0).Databas es(0)
    > Set rs = db.OpenRecordse t("SELECT * From qryPlannedMaint enance[/color]
    WHERE[color=blue]
    > [EquipmentNumber] = '" & EquipmentNumber & "';")
    > rs.MoveFirst
    > rs.Edit
    > rs![LastMaintenance] = Date
    > rs.Update
    > rs.Close
    >
    > Set rs = Nothing
    > Set db = Nothing
    >
    > At the moment I am getting this run time error on the Set rs line:
    > Run-time error 3464. Data type mismatch in criteria expression.
    >
    > Any suggestions?
    >
    > Thanks in advance
    >
    >[/color]


    Comment

    Working...