Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2009
    Location
    Gatineau, Quebec Canada
    Posts
    147
    Provided Answers: 1

    Unanswered: Run Time Error 3346

    Greetings all,

    I have a bizarre problem -- a single computer is generating a 3346 message -- " the number of queries and destination fields are not the same". Three other computers running the same operating system (Windows 7) do NOT generate the error -- they run the code without problem.

    The error in the one machine is generated when a function is called from a form on the on_load event. The function is in a general module, and reads as follows:

    Public Function owing()
    DoCmd.SetWarnings False

    ' delete old records

    DoCmd.RunSQL "delete from etudOwing"

    Dim db As DAO.Database
    Dim rs1 As DAO.Recordset

    Set db = CurrentDb

    Dim aPaid As Double
    Dim aOwing As Double
    Dim aParent As Integer

    Dim paidUp As Boolean
    Dim SQL1 As String
    SQL1 = "select ID from parents"
    Dim SQL2 As String
    Set rs1 = db.OpenRecordset(SQL1, dbOpenDynaset)

    If rs1.BOF And rs1.EOF Then
    Else
    rs1.MoveFirst
    Do While Not rs1.EOF
    aParent = rs1("id")
    aPaid = Nz(DSum("amount", "payments", "aParent = " & aParent), 0)
    owing = Nz(DSum("f_cost", "qrycoursestaken", "par_id = " & aParent), 0)
    If (owing - aPaid > 0) Then
    paidUp = 0
    Else
    paidUp = -1
    End If
    SQL2 = "INSERT INTO etudOwing (aParent, paid, owing, apaidUp) VALUES (" & aParent & ", " & aPaid & "," & owing & "," & paidUp & " )"
    DoCmd.RunSQL SQL2

    rs1.MoveNext
    Loop

    rs1.Close
    End If

    DoCmd.SetWarnings True
    ' MsgBox "Table updated!", "EVO"
    End Function

    ***********

    Any idea why a single computer would be generating this error (but other computers do not)?

    Regards

    J. Smith

    Aylmer, Quebec

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    The first question that has to be asked is whether or not this database has been split, as it needs to be, in a multi-user environment, into a Back End (with all Tables) located on a shared drive, and a copy of the Front End (with everything except the Tables) on each user's PC?

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    This is strange, indeed.

    1. On the machine that generates the error, change the code, like this:
    Code:
    SQL2 = "INSERT INTO etudOwing (aParent, paid, owing, apaidUp) VALUES (" & aParent & ", " & aPaid & "," & owing & "," & paidUp & " )"
    Debug.Print SQL2
    Stop
    DoCmd.RunSQL SQL2
    2. Open the immediate windows (Ctrl+G) and call the Function owing().

    3. When the execution stops, copy the value of SQL2 printed in the immediate windows.

    4. Open a new query, switch to SQL view and paste what you copied from the immediate windows into it.

    5. Switch the query to datasheet view and see what happens. Usually, the query builder delivers more detailed error messages than VBA and what's wrong (or what it does not like) in the query expression should appear highlighted.
    Have a nice day!

  4. #4
    Join Date
    Mar 2009
    Location
    Gatineau, Quebec Canada
    Posts
    147
    Provided Answers: 1
    Thanks for the interest. It is a single-user ap, but I put it on a $269 refurbished computer. I am the treasurer / programmer of a sailing club / sailing school. We have been having some trouble with the refurbished computer, and its gone back and forth to the vendor, but the problem persists. May be some strange problem with the hardware (the owing function may be using a lot of memory, and I suspected a memory problem, but the vendor could find none).

    Thanks again,

    John S

  5. #5
    Join Date
    Mar 2009
    Location
    Gatineau, Quebec Canada
    Posts
    147
    Provided Answers: 1
    Hi Sinndho,

    I will try this out, and report back. Learn something new every day! We always have to remember that we learn a lot from dealing with errors, but they are none the less painful!

    Thanks again,

    John S

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    id suspect a data error with that message (assuming that the same application ius being used on multiple computers.

    however you say that its a single user app, but is used on multiple computers... if there is the slightest risk that app may be used by more than one person concurrently then split it.

    if you are getting errors on remote machines try writing an error message to a logfile/table if an error occurs. that way round you cna see what the runtime is whining about, rather than trying to get the details of what the user was doing when things went belly up
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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