Results 1 to 2 of 2
  1. #1
    nika.duncan is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2013
    Posts
    36

    Number of Query values and destination fields are not the same - Run-time error 3346

    Hi


    I am receiving the error above when I try to execute the code below. I have checked the fields in the code as well as the table and I can't see what I am missing. The tblMeasure table which is the subform have the following fields:
    • MUserLoginID - Number
    • MainMeasureID - AutoNumber - Primary Key
    • MeasureName - Text
    • MPositonName - Text
    • MeasureScore - Number
    • MeasureWeight - Number
    • MeasureTotal - Number
    • MeasureDesc - Memo
    • MStaffApraisedID - Number


    The UserDeatils table which is the main form have the following fields:
    • StaffID - Number
    • StaffName - Text
    • DepartmentName - Text
    • StaffPosition - Text
    • StaffGrade - Text
    • StaffBDate - Date
    • StaffEDate - Date
    • StaffApraisedID - AutoNumber - Primary Key


    The link between the two forms are StaffApraisedID to MStaffApraisedID then StaffID to MUserLoginID then StaffPosition to MPositonName. When I select a member and click the Duplicate button I received the error above. The area highlighted in red is where it errors out.

    I will really appreciate any help at this time as I am not sure what to do at this point. The code is attached below
    Thanks.
    Nika
    Code:
    Private Sub cmdDuplicateData_Click()
    On Error GoTo Err_cmdDuplicateData_Click
    Dim OldStaffID As Integer, NewStaffID As Integer
    OldStaffID = Me.StaffApraisedID
    
    'Add new record to end of Recodset  Object
    With Me.RecordsetClone
    .AddNew
    !StaffName = Me!StaffName
    !DepartmentName = Me!DepartmentName
    !StaffPosition = Me!StaffPosition
    !StaffBDate = Me!StaffBDate
    !StaffEDate = Me!StaffEDate
    !StaffID = Me!StaffID
    !StaffGrade = Me!StaffGrade
    NewStaffID = !StaffApraisedID
    .Update
    End With
    
     CurrentDb.Execute "INSERT INTO tblMeasure(MainMeasureID, MUserLoginID, MStaffApraisedID, MeasureName, MPositonName, MeasureScore, MeasureWeight, MeasureTotal, MeasureDesc)" & _
    "SELECT MainMeasureID, MUserLoginID, MStaffApraisedID, MeasureName, MPositonName, MeasureScore, MeasureWeight, MeasureTotal, MeasureDesc, " & NewStaffID & " AS NewStaffID " & _
    "FROM tblMeasure " & _
    "WHERE MStaffApraisedID =" & OldStaffID & ";"
    
    
    DoCmd.GoToRecord , , acLast
    Exit_cmdDuplicateData_Click:
    Exit Sub
    Err_cmdDuplicateData_Click:
    MsgBox Error$
    Resume Exit_cmdDuplicateData_Click:
    
    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Do not include Totals in your Table. Totals can be calculated when necessary by using queries. Normalize your tables. Use atomic fields == 1 fact 1 field.

    Readers only know what you tell us, so until we understand your business/opportunity, we can not provide focused comments/advice.
    The key to successful database is to understand your business and rules, and ensure that your database structure (tables and relationships) match/support your business.

    I would suggest focussing on your tables and relationships before getting into forms etc.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 10-29-2013, 12:59 PM
  2. Replies: 19
    Last Post: 08-08-2013, 01:17 PM
  3. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  5. Replies: 10
    Last Post: 12-15-2010, 11:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums