• VBA says can’t find a method, but its so there. Code included

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » VBA says can’t find a method, but its so there. Code included

    Author
    Topic
    #480595

    So I have been changing my working unbound form (updates a table) slowly to match the data that I want to put in it. Suddenly when I changed cboSixth to cboBuyerFee, it stopped working and said it couldnt find the method cboBuyerFee.. so I fiddled with it, changed the name, changed it back.. now, its giving me the same error on a box that worked fine just a few min ago. It now stops when it trys to populate the table from me.cboBuyer. But as you can see, its clearly there.. and the syntax was fine a moment ago? is there ever a need to clear or reset variables, or methods? Here’s the code:

    Private Sub MethodSubmitForm_Click()
    Dim strSQL As String
    strSQL = _
    “INSERT INTO tblTheGoods ” & _
    “(FirstData, SecondData, ThirdData, FourthData, FifthData, SixthData, SeventhData, EighthData)” & _
    ” VALUES (” & _
    “‘” & Me.cboCarMake & “‘, ” & _
    “‘” & Me.cboCarModel & “‘, ” & _
    “‘” & Me.cboColor & “‘, ” & _
    “‘” & Me.cboSeller & “‘, ” & _
    “‘” & Me.cboBuyer & “‘, ” & _
    “‘” & Me.cboBuyerFee & “‘, ” & _
    “‘” & Me.cboSeventh & “‘, ” & _
    “‘” & Me.cboEighth & “‘)”

    CurrentDb.Execute strSQL, dbFailOnError
    End Sub

    —————————-

    Now, I know you may wonder whether or not I have named the combo boxes correctly. I have double and triple checked that.. retyped it, etc. The form has cboBuyer and cboBuyerFee, just like that. And, remember that the cboBuyer worked fine before my original error.

    Viewing 3 reply threads
    Author
    Replies
    • #1311370

      ok, update. I did find a space before cboBuyerFee in the form properties. I fixed that, but the error had reverted to the cboBuyer method.. now that i have taken the space out of cboBuyerFee, the error has gone back to that method. Very stumped now. I was hoping I could actually include the small file to look at, but I am not seeing that option.

      • #1311384

        SO, if you get this error

        access 2003 compile error method or data member not found access 2003

        Try going to the line in your code AFTER the method that gets highlighted. Check your naming conventions, and you might find the problem. FOr some reason, it doesnt tell you the right line that gave it issues, it tells you the line before which is CORRECT.

    • #1311405

      I agree that this is confusing. I have been caught by this a few times.
      I think what it means is that the highlighted row is the last good row before the problem.

    • #1311531

      I find that when you split a line using & _ then the debugger has trouble highlighting the correct part of the statement. I prefer to not ever split lines with & _ whcih avoids this issue.

      • #1313976

        Hi Karl,

        Try using a debug.print statement to print the SQL statement to the Immediate Window:

        “‘” & Me.cboSeventh & “‘, ” & _
        “‘” & Me.cboEighth & “‘)”

        Debug.Print strSQL ‘<—Add this line of code

        CurrentDb.Execute strSQL, dbFailOnError
        End Sub
        ——————————–

        Run your procedure. Then open the Immediate Window using or View | Immediate Window. You should see the SQL statement. Click on the Stop button, if necessary, to stop the code (Run | Reset). Copy the SQL statement to the clipboard. Open a new query, switch to SQL view, and paste your SQL statement in as a new append query. Try running it. Does it work there?

        If you cannot get the procedure to run at all, try using the undocumented /decompile switch while opening your application. Then, follow this up with a Compact & Repair. Finally, see if you can get the code to compile.

        • #1314073

          Hey thanks Tom.. I learned a hard lesson about debugging, wasted several hours. Common things a newbie has to struggle through, but I came out more knowledgeable on the other side.. I actually knew about a command that would somehow track your code, the one you just mentioned, but I didn’t fully understand how to execute it. Will come in handy.

    • #1313992

      Tom,

      Welcome to the lounge as a poster. :cheers:
      Always nice to have another poster with your credentials in the lounge.

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    Viewing 3 reply threads
    Reply To: VBA says can’t find a method, but its so there. Code included

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: