Results 1 to 10 of 10
  1. #1
    Dealbarta is offline Novice
    Windows 11 Office 365
    Join Date
    Apr 2024
    Location
    Bampton, Devon, U.K.
    Posts
    5

    Selecting an item from an Unbound Combo Boxes dropdown list has stopped working

    I have a database of plants (trees, shrubs, herbaceous perennials, etc) which I have planted in two gardens (Blackwithies and The Nook) originally developed using Access 2002. From time to time I have modified it to add features which I required and it has always worked perfectly with successive versions of Access.
    After a hard drive failure I had to do a clean install of Windows 11 and all my apps. Fortunately I had a backup of my data. However, since the reinstallation all the Unbound Combo Boxes have stopped working giving the VBA error message ‘Can’t find project or library’. Other controls such as List Boxes and Option Buttons using macros continue to work perfectly.
    There are three forms which contain Unbound Combo Boxes in which I can enter details of plants – PLANTS, PLANTS at BLACKWITHIES and PLANTS at THE NOOK – all based on a table named PLANTS. All the forms have fields for entering Genus, Species, Variety and Cultivar into the PLANTS table. There are also other fields from the PLANTS table which are not pertinent to this question. A query (FIND PLANT) combines the four fields mentioned above into a FullPlantName. It also has a hidden field which sorts the plants into alphabetical order. The FIND PLANT query is used as the Row Source in an Unbound Combo Box to select a plant to be displayed by the form. As the problem is common to all three forms I will describe its manifestation in the PLANTS form
    The PLANTS form displays pictures of plants using an ActiveX control DBPics 2.0 downloaded from Ammara (see Figure 1). I use the FIND PLANT query in an Unbound
    Combo Box (labelled FIND) to generate a list of plants in alphabetical order which I can scroll down to select the plant which I want the PLANTS form to display (see Figure 2).
    However, when I click on a plant name I get the VBA window for the Form_PLANTS code with the error message,
    Compile error:


    Can’t find project or library
    The VBA for the After Update [Event Procedure] for the Unbound Combo Box using the FIND PLANT query as the Row Source is:
    Private Sub Combo249_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = " & Str(Me![Combo74])
    Me.Bookmark = rs.Bookmark
    End Sub
    The ID is the key to PLANTS and is used in the FIND PLANT query to link the two together. When a failure occurs the first line is highlighted in yellow and the Str in blue (see Figure 3).
    The Data for the Combo Box is shown in Figure 4.
    I am not really conversant with Access VBA so I cannot work out what is wrong. Can anyone help? I would be most grateful.
    Click image for larger version. 

Name:	Figure 1.jpg 
Views:	18 
Size:	127.3 KB 
ID:	51678Click image for larger version. 

Name:	Figure 2.jpg 
Views:	18 
Size:	285.5 KB 
ID:	51679Click image for larger version. 

Name:	Figure 3.jpg 
Views:	18 
Size:	17.6 KB 
ID:	51680Click image for larger version. 

Name:	Figure 4.png 
Views:	18 
Size:	14.7 KB 
ID:	51681

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Have you checked for missing References on the Tools menu when in the Visual Basic Editor window?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    What is Str for? I looks like it might be a conversion function (that would be CStr, not Str). Or Str could be a UDF. AFAIK, there is no Str function in Access.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Dealbarta is offline Novice
    Windows 11 Office 365
    Join Date
    Apr 2024
    Location
    Bampton, Devon, U.K.
    Posts
    5
    Hello Bob, I've checked the References - see screenshot - and the only one which is shown as missing is dbPix 3.0 ActiveX Control module which I do no use. I am not sure why some references are ticked.Click image for larger version. 

Name:	References for Plants.png 
Views:	15 
Size:	22.2 KB 
ID:	51683

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    As Micron pointed out you need to remove the Str() function. Is the ID field numeric (it should, usually autonumber)? If yes then simply remove the Str() and make sure the combo (I would suggest you give it a more meaningful name like cboFind) has two columns (ID and FullPlantName) and its Columns property is set to 2 and Column Widths set to 0";5" (or whatever width is big enough to display the longest plant name). Once you do that it should work.
    I suggest you also remove the missing reference if not in use.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    Dealbarta is offline Novice
    Windows 11 Office 365
    Join Date
    Apr 2024
    Location
    Bampton, Devon, U.K.
    Posts
    5
    Quote Originally Posted by Gicu View Post
    As Micron pointed out you need to remove the Str() function. Is the ID field numeric (it should, usually autonumber)? If yes then simply remove the Str() and make sure the combo (I would suggest you give it a more meaningful name like cboFind) has two columns (ID and FullPlantName) and its Columns property is set to 2 and Column Widths set to 0";5" (or whatever width is big enough to display the longest plant name). Once you do that it should work.
    I suggest you also remove the missing reference if not in use.
    Cheers,
    Hello Vlad,
    I confirm that the ID field is the autonumber. I can also confirm that the Column Count is 2 (ID and FullPlantName), and the Column Widths are 0cm;5.875cm which is fine for displaying the longest name.
    Because I know almost nothing about VBA I am not sure how much code to delete to remove the Str( ) function. When I just deleted Str(Me![Combo249]) I got the error message,
    Compile Error
    Syntax Error
    Should it be replaced by something else?

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Like this:
    Code:
    rs.FindFirst "[ID] = " & Me.Combo74   '& Str(Me![Combo74])
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,945
    Gove yourself some decent control names. combo249 is not going to mean anything to anyone 6 months down the road.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Dealbarta is offline Novice
    Windows 11 Office 365
    Join Date
    Apr 2024
    Location
    Bampton, Devon, U.K.
    Posts
    5
    Hello Vlad,
    Many thanks. Using your guidance I have now updated the VBA for all my Combo Boxes and everything is working fine.
    I can now get back to using my garden database instead of tearing my hair out!

  10. #10
    Dealbarta is offline Novice
    Windows 11 Office 365
    Join Date
    Apr 2024
    Location
    Bampton, Devon, U.K.
    Posts
    5
    I will do.

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

Similar Threads

  1. Replies: 1
    Last Post: 04-18-2019, 03:06 PM
  2. Replies: 5
    Last Post: 01-07-2019, 01:51 AM
  3. Data not filtered after selecting item in the list box
    By sukhjinder in forum Programming
    Replies: 4
    Last Post: 08-15-2017, 09:40 AM
  4. Replies: 1
    Last Post: 07-12-2012, 08:39 AM
  5. Dropdown List: Use Each Item Once?
    By Heavy Doody in forum Access
    Replies: 1
    Last Post: 05-02-2011, 07:44 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