Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.

  2. #2
    New Lounger
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  3. #3
    New Lounger
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Solution. Access 2003 debugger confusion

    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.

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    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.
    Regards
    John



  5. #5
    3 Star Lounger HiTechCoach's Avatar
    Join Date
    Sep 2011
    Location
    Oklahoma City, OK
    Posts
    200
    Thanks
    0
    Thanked 31 Times in 30 Posts
    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.
    Boyd Trimmell aka HiTechCoach (Access Information here)
    Microsoft MVP - Access Expert
    "If technology doesn't work for people, then it doesn't work."

  6. #6
    Star Lounger tgw7078's Avatar
    Join Date
    Jul 2010
    Location
    Seattle, WA., USA
    Posts
    90
    Thanks
    1
    Thanked 12 Times in 12 Posts
    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 <Ctrl><G> 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.
    Tom Wickerath
    Microsoft Access MVP
    4/1/2006 - 3/31/2012

  7. #7
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Tom,

    Welcome to the lounge as a poster.
    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!

    My Systems: Desktop Specs
    Laptop Specs

  8. #8
    New Lounger
    Join Date
    Dec 2011
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •