Solved

Access 2013 Compile Error in Sub

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

690 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