Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run time error 3061 (Win XP Access 2003)

    When I run this code, I get a "Run time error 3061. Too few parameters. Expected 1" with the cursor on the "Set rst2" statement. Any thoughts?

    Option Compare Database
    Option Explicit

    Private Sub Command5_Click()
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim rst1 As DAO.Recordset
    Dim rst2 As DAO.Recordset
    Dim IDMaterial As Integer
    Dim IDMaterialLU As Integer
    Dim strSQL As String
    Dim strSearch As String
    Dim Temp As Double
    Dim UnitCost As Currency


    Set dbs = CurrentDb()
    Set rst = dbs.OpenRecordset("tblMasterInv", dbOpenDynaset)
    Set rst1 = dbs.OpenRecordset("tblMovimientos", dbOpenDynaset)
    strSQL = "SELECT * FROM tblFormulaDetail WHERE [NumOT] = " & Me!NumOT
    Set rst2 = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)

    If IsNull(Me!NumOT) Then
    MsgBox " No hay OT."
    Exit Sub
    End If

    Do While Not rst2.EOF 'tblFormulaDetail

    With rst 'tblMasterInv
    IDMaterial = rst2!IDMaterial
    strSearch = "[IDMaterial] = " & IDMaterial
    .FindFirst strSearch
    If .NoMatch Then
    MsgBox "ID " & IDMaterial & " not found"
    Exit Sub
    Else
    Temp = !SaldoInicial - Nz(rst2!Cantidad, 0)
    .Edit
    UnitCost = !CostoUnitarioFijo
    !SaldoInicial = Temp
    !CostoInicial = !SaldoInicial * UnitCost
    .Update
    End If
    .Close
    End With

    With rst1 'tblMovimientos
    .AddNew
    !IDMaterialLU = rst2!MaterialID
    !Salida = rst2!Cantidad
    !CostoSalida = UnitCost * rst2!Cantidad
    !Saldo = Temp
    !CostoSaldo = Temp * UnitCost
    !FechaTransaccion = rst2!Fecha
    !TimeSequence = Now()
    !Cuenta = rst2!NumOT
    .Update
    .Close
    End With
    rst2.MoveNext
    Loop
    rst2.Close

    Me!NumOT.SetFocus
    MsgBox " Transacci

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

    Re: Run time error 3061 (Win XP Access 2003)

    This error means that the Jet Engine doesn't recognize a name or expression in the SQL statement.

    1) Are you absolutely sure that NumOT is a field in tblFormulaDetail and that is is spelled correctly?

    2) If NumOT is a text field, you must put quotes around the value. This can be done by concatenating with Chr(34):

    strSQL = "SELECT * FROM tblFormulaDetail WHERE [NumOT] = " & Chr(34) & Me!NumOT & Chr(34)

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run time error 3061 (Win XP Access 2003)

    I needed the Chr(34). Sorry. I should have known that.

Posting Permissions

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