Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Not A Simple Question (A2000)

    I'm getting "Runtime error 3061" "too few parameters-expected 1"
    With the following code halting on the line that reads:

    Set rst = db.OpenRecordset(STRSQL, dbOpenDynaset)

    Can anyone see why this would happen.?



    If IsNull(Me.txtVehicleID) Or Me.txtVehicleID = "" Then
    MsgBox " No Vehicle Selected", vbInformation
    GoTo SkipCode
    Else
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim strFilter As String
    Dim STRSQL As String
    Dim strValue As String
    Set db = CurrentDb
    strFilter = "tblvehicledetails.Registration = " & Forms!frmCourtesyCarPlanner!txtVehicleID
    STRSQL = "Select * From tblvehicledetails Where " & strFilter
    Set rst = db.OpenRecordset(STRSQL, dbOpenDynaset)
    If rst.RecordCount = 0 Then
    DoCmd.OpenForm "frmvehicledamage"
    DoCmd.GoToRecord acDataForm, "frmvehicledamage", acNewRec
    Forms!frmVehicleDamage!Registration = Forms!frmCourtesyCarPlanner!txtVehicleID
    Forms!frmVehicleDamage!AccidentDate.SetFocus
    Forms!frmVehicleDamage.Caption = "Vehicle Registration"
    Else
    DoCmd.OpenForm "frmvehicledamage", acViewNormal, , strFilter
    Forms!frmVehicleDamage.Caption = "Vehicle Registration"
    Forms!frmVehicleDamage!AccidentDate.SetFocus
    End If
    SkipCode:
    End If
    Exit Sub

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

    Re: Not A Simple Question (A2000)

    This error means that the database engine encounters a name that is not recognised as an existing field name. There are two possibilities:
    1. <LI>Registration is not a field in tblVehicleDetails (check the exact spelling), or
      <LI>Registration is a text field; in that case the VehicleID should be enclosed in quotes:

      strFilter = "tblVehicleDetails.Registration = " & Chr(34) & Forms!frmCourtesyCarPlanner!txtVehicleID & Chr(34)

      otherwise the value of txtVehicleID will be interpreted as a field name - which doesn't exist. Chr(34) is a double quote ".
    HTH,
    Hans

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Not A Simple Question (A2000)

    Very good Hans.
    strFilter = "tblVehicleDetails.Registration = " & Chr(34) & Forms!frmCourtesyCarPlanner!txtVehicleID & Chr(34)x100 <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>
    This was the problem.

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

    Re: Not A Simple Question (A2000)

    So it was a simple question after all...

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Not A Simple Question (A2000)

    Yes, for you it's <img src=/S/yawn.gif border=0 alt=yawn width=15 height=15>

    For me, <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>



    <img src=/S/sarcasm.gif border=0 alt=sarcasm width=15 height=15> You obviously saw the x100 thought i could catch you out there. <img src=/S/sneaky.gif border=0 alt=sneaky width=15 height=15>

Posting Permissions

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