Solved

Access 2013 Compile Error in Sub

Posted on 2015-01-28
5
93 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
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
What is the specific error message you are getting?
0
 

Author Comment

by:ggodwin
Comment Utility
Method or Data member not found
0
 

Accepted Solution

by:
ggodwin earned 0 total points
Comment Utility
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
Comment Utility
Yup, that would do it.  Yet another reason why you should never, ever use spaces in object names :)
0
 

Author Closing Comment

by:ggodwin
Comment Utility
Because I found the problem on my own.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now