Solved

Access 2013 Compile Error in Sub

Posted on 2015-01-28
5
97 Views
Last Modified: 2016-02-11
Experts,
I am getting a compile error on the below line of code. I just added this step today and now getting the error.
I have confirmed that the table has the field SupplierName. It has been since 2009 since the code was added/designed so I assume that I'm overlooking something simple.

  qdTMMK.Parameters(5) = Me.SupplierName


Sub CopyMultipleTMMK_SelectByTagNumber()
Dim rsTMMK As DAO.Recordset
Dim qdTMMK As QueryDef
Dim reccountTMMK As Long
Dim copycountTMMK As Long
Dim msgStringTMMK As String
 
Set rsTMMK = Me.qSkpiInvestigationTMMKsubform.Form.RecordsetClone
If Not ((rsTMMK.BOF) And (rsTMMK.EOF)) Then
    rsTMMK.MoveLast
    reccountTMMK = rsTMMK.RecordCount
    Debug.Print reccountTMMK & " records in subform"
    rsTMMK.MoveFirst
     
    For ctr = 1 To rsTMMK.RecordCount
        If rsTMMK.Fields("Copy") = True And rsTMMK("tagNumber") <> Me.TagNumber Then
            copycountTMMK = copycountTMMK + 1
            Debug.Print "*** Copying details to SKPI with Tagnumber " & rsTMMK.Fields("tagNumber")
            Set qdTMMK = CurrentDb.QueryDefs("qryUpdateSKPI_TagNumber")
            qdTMMK.Parameters("strTagNumber") = rsTMMK.Fields("tagNumber")
            'Fill in the form-based params
            qdTMMK.Parameters(1) = Me.DateInvestigationIssued
            qdTMMK.Parameters(2) = Me.RCOccurence
            qdTMMK.Parameters(3) = Me.RCDetection
            qdTMMK.Parameters(4) = Me.RCCategory
            qdTMMK.Parameters(5) = Me.SupplierName
            qdTMMK.Parameters(6) = Me.Responsible
            qdTMMK.Parameters(7) = Me.dispute
            qdTMMK.Parameters(8) = Me.CMOccurence
            qdTMMK.Parameters(9) = Me.CMDetection
            qdTMMK.Parameters(10) = Me.CMCategory
            qdTMMK.Parameters(11) = Me.DateCMImplemented
            qdTMMK.Parameters(12) = Me.Status
            qdTMMK.Parameters(13) = Me.WeeklyUpdate
            qdTMMK.Parameters(14) = Me.WeeklyUpdateDate
'            For x = 0 To qdTMMK.Parameters.Count - 1
'                Debug.Print x; qdTMMK.Parameters(x).Name & vbTab & vbTab & qdTMMK.Parameters(x).Value
'            Next
            qdTMMK.Execute
            Set qdTMMK = Nothing
        ElseIf rsTMMK("tagNumber") = Me.TagNumber Then
            Debug.Print "Skipping TagNumber" & rsTMMK("tagNumber") & " because it is the record being edited in the main form."
        End If
        rsTMMK.MoveNext
    Next
    msgStringTMMK = "Details were copied to " & copycountTMMK & " records."
Else
    msgStringTMMK = "No records in subform!"
End If
    MsgBox msgStringTMMK, vbOKOnly + vbInformation, "Copy to multiple SKPIs"
Set qdTMMK = Nothing
Set rsTMMK = Nothing
End Sub

Open in new window


Any help would be appreciated.
0
Comment
Question by:ggodwin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 40575644
What is the specific error message you are getting?
0
 

Author Comment

by:ggodwin
ID: 40575657
Method or Data member not found
0
 

Accepted Solution

by:
ggodwin earned 0 total points
ID: 40575703
I beleive I found the problem

In one of my forms I hade the field named. "Supplier Name" instead of "SupplierName".
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 40577802
Yup, that would do it.  Yet another reason why you should never, ever use spaces in object names :)
0
 

Author Closing Comment

by:ggodwin
ID: 40583525
Because I found the problem on my own.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question