Results 1 to 7 of 7
  1. #1
    hellojosie is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    16

    compile error: expected sub, function or property

    I have been researchin this issue all morning.

    I am getting this error on some code I'm trying to run:

    Compile error: expected sub, function or property

    What does the error message mean?



    It highlights a field I am refrencing but the field name is correct?

    This is the code and I have typed in red the part the error refers to:

    Sub DriversAvailable2()
    Dim mydb As Database
    Dim myset As Recordset
    Dim strList As String
    Set mydv = CurrentDb()
    Set myset = mydb.OpenRecordset("qryDriversAvailable")
    strList = "This is a list of available drivers: " & vbCrLf
    myset.MoveFirst
    Do While Not myset.EOF
    strList -strList & myset![FullName] & vbCrLf
    myset.MoveNext

    Loop
    MsgBox strList
    End Sub

    Thank you for any help and direction in advance!!!!

  2. #2
    randman1 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2009
    Posts
    25
    You've got a minus sign rather than an equals sign. Try:

    strList = strList & myset![FullName] & vbCrLf

  3. #3
    hellojosie is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    16
    Hi randoman,

    Eeek thanks for that!!!

    The error message is still coming up though.

    Any other ideas? Please help!!!!!

  4. #4
    randman1 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2009
    Posts
    25
    Well, according to your text above, you have another type-o but I wouldn't expect a compile error on the line you highlighted:

    Dim mydb As Database
    Set mydv = CurrentDb() '<--- Should be mydb

    I would expect an 'object not set' error on the line

    Set myset = mydb.OpenRecordset("qryDriversAvailable")

  5. #5
    hellojosie is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    16
    Hi again!

    This is really embarasing hey.

    I have fixed that type-o and I am still getting the error.

    Actually I did get an error 3601 for a change for a moment and then it went back to the usual compile error.

    Continuing to research and I can't find anything to help. Feeling really deflated.

    Please help!!!!

  6. #6
    randman1 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2009
    Posts
    25
    The only other thing that I can think of is to explicitly refer to the Value property of the recordset field such as

    strList = strList & myset![FullName].Value & vbCrLf



    I use recordsets all the time and usually don't explicitly refer to the Value property unless I'm working with collections. However, I do explicitly declare the DAO library. For example:

    Dim mydb As DAO.Database
    Dim myset As DAO.Recordset

    Depending on your references and the order in which they appear, you could be implicitly referencing the ADO library. Just to be clear, you get the error when the code runs and the same element is highlighted as you describe in your original post?

  7. #7
    hellojosie is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Posts
    16
    Thanks for replying again!!!

    Do you mean the MS DAO 3.6 object library?

    I tried to check this earlier and move it up and I got a DLL error message.

    I know I have stated that I am working in Access 2007 but it is actually 2010. I don't know why but on the data base it shows 2007 up the top but the properties of access show 2010.

    Anyway I did some research on the DLL error message and came out with the DAO was not neccessary because Access 14. does what the DAO does?

    I'm so confused and really appreciate you looking at this.

    I will also try your other suggestion-Thanks so much!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 09-28-2011, 09:20 PM
  2. Compile error: code or function not defined
    By GeorgeBrown in forum Access
    Replies: 1
    Last Post: 09-19-2011, 10:25 AM
  3. Compile error. Sub of function not defined
    By plavookins in forum Reports
    Replies: 7
    Last Post: 04-22-2011, 10:15 AM
  4. Replies: 8
    Last Post: 01-19-2011, 04:48 AM
  5. compile error: expected end of statement
    By RedGoneWILD in forum Programming
    Replies: 5
    Last Post: 07-29-2010, 10:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums