Solved

Access 2013 Compile Error in Sub

Posted on 2015-01-28
5
95 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

786 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