Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2004
    Location
    Walnut Cove, NC
    Posts
    101

    Unanswered: Error : Method or data member not found

    I have converted an Access 2.0 application to Access 2000.

    I have a form that has an option box where the user chooses either
    All teams (=value of 1) or a specific team name (=value of 2). If Option 2 is selected, a list box appears allowing you to choose the team name. After the selections are made and the Print Selection button is pressed, I get the error message "method or data member not found" in the following code:

    If Forms![NMR_Report_Form]![select_team] = 2 Then
    sql_code = sql_code & " AND (NMR_Table.NMR_Team=[Forms]![NMR_Report_Form]![Team_Index])"
    Set teamset = myDB.OpenRecordset("SELECT DISTINCTROW Team_Table.Team_Name FROM Team_Table WHERE ((Team_Table.Team_Number=" & [Forms]![NMR_Report_Form]![Team.Box] & ")); ", dbOpenDynaset)
    Selection = IIf(Not IsNull(Selection), Selection & ", " & teamset.Team_Name & " Team", teamset.Team_Name & " Team")
    End If

    The error stops on the last line before the End if and highlights the .Team_name.

    I get this error message if I choose option 1 or option 2. I don't understand why it is executing this code if select_team =1.

    Any help would be much appreciated!

    Thanks,

    SBR7770

  2. #2
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    It looks like a compile error, not a run-time error (the code is not executed at all, it just tells you there are errors).

    What is teamset?
    And what property of teamset is Team_Name?

    Dan
    Daniel Vlas

    Access Addict

  3. #3
    Join Date
    Jan 2004
    Location
    Walnut Cove, NC
    Posts
    101
    Originally posted by DannyY
    It looks like a compile error, not a run-time error (the code is not executed at all, it just tells you there are errors).

    What is teamset?
    And what property of teamset is Team_Name?

    Dan
    This is at the beginning of the function:

    Function NMR_Report()

    Dim printNMR As QueryDef, myDB As Database
    ReDim sort_code(1 To 8)
    Dim NMRset As Recordset
    Dim teamset As Recordset

    Teamset is the table called Team_Table and Team_Name is a field in the table. The statement that is causing the error is supposed to get the team name and print it at the top of a report in a field called Selection. If I remark out the statement, the report prints fine, but the team name doesn't appear at the top.

    Thanks for your help.

  4. #4
    Join Date
    Nov 2002
    Location
    Wyoming
    Posts
    48
    Originally posted by sbr7770
    This is at the beginning of the function:

    Function NMR_Report()

    Dim printNMR As QueryDef, myDB As Database
    ReDim sort_code(1 To 8)
    Dim NMRset As Recordset
    Dim teamset As Recordset

    Teamset is the table called Team_Table and Team_Name is a field in the table. The statement that is causing the error is supposed to get the team name and print it at the top of a report in a field called Selection. If I remark out the statement, the report prints fine, but the team name doesn't appear at the top.

    Thanks for your help.
    Try changing teamset.Team_Name to teamset!Team_Name.

    Also, when you name your recordsets, try a prefix like rst. So, teamset would be rstTeamset. It makes your code easier to read.

    HTH
    Cheers,
    Ken

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    do you have a references problem?

    try:

    [ALT][F11] Tools¦References and select Microsoft DAO 3.6 object library

    Then change any
    Dim Xxxx as recordset
    to
    Dim Xxxx as DAO.recordset

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    Replace
    teamset.Team_Name
    with
    teamset.Fields("Team_Name")
    Daniel Vlas

    Access Addict

  7. #7
    Join Date
    Jan 2004
    Location
    Walnut Cove, NC
    Posts
    101
    Originally posted by KennyG
    Try changing teamset.Team_Name to teamset!Team_Name.

    Also, when you name your recordsets, try a prefix like rst. So, teamset would be rstTeamset. It makes your code easier to read.

    HTH
    Thanks Kenny!

    When I changed the . to an ! it worked. I agree with you on the naming convention. I was taught to name them as you suggest when I took Visual Basic classes. Unfortunately this code was written back in 1992 by someone else, so I had nothing to do with the naming convention used. Thanks again!!!!!!

    Sherry

  8. #8
    Join Date
    Nov 2002
    Location
    Wyoming
    Posts
    48
    Glad I could help!

    I suppose I should not have assumed it was your code.
    Cheers,
    Ken

  9. #9
    Join Date
    Jan 2004
    Location
    Walnut Cove, NC
    Posts
    101
    Originally posted by DannyY
    Replace
    teamset.Team_Name
    with
    teamset.Fields("Team_Name")


    Thanks Danny! That worked!

    Changing teamset.Team_Name to teamset!Team_name also worked (suggested by Kenny).

    Thanks to both of you!

    Sherry

Posting Permissions

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