Results 1 to 10 of 10
  1. #1
    TeamTraveler is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    May 2015
    Posts
    18

    Unbound combobox doesn't pull in ALL records

    Can someone please suggest some reasons why an unbound combobox used to pull records from a table into a form will pull some of the records in but not ALL of them.



    The combobox has an After Update embedded macro with the following:

    Record - First
    Where Condition = = "[HotelName] = " & "'" & [Screen].[ActiveControl] & "'"

    Thank you in advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Post the SQL statement of the form RecordSource. Does it have multiple tables with INNER JOIN?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    TeamTraveler is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    May 2015
    Posts
    18
    Quote Originally Posted by June7 View Post
    Post the SQL statement of the form RecordSource. Does it have multiple tables with INNER JOIN?
    This is a Hotel Input form tied to a Hotel Master table.

    SELECT Hotels.HotelID, Hotels.HotelName, Hotels.DNU, Hotels.Address1, Hotels.Address2, Hotels.City, Hotels.State, Hotels.Zip, Hotels.Contact1Name, Hotels.Contact1Title, Hotels.ContactPhone1, Hotels.Contact1Email, Hotels.Contact2Name, Hotels.Contact2Title, Hotels.ContactPhone2, Hotels.Contact2Email, Hotels.HotelMgmtGroup, Hotels.TACityRank, Hotels.[TA%], Hotels.[TA#Reviews], Hotels.PayComm, Hotels.[Comm%], Hotels.[InteriorRooms?], Hotels.[DblQueens?], Hotels.[BusinessSvcs?], Hotels.[ExerciseArea?], Hotels.[FreeParking?], Hotels.[Guest Laundry?], Hotels.BfastType, Hotels.NearbyEating, Hotels.WillingnessToUse, Hotels.[FreeMeetRooms?], Hotels.ApplicableTaxRate, Hotels.GeneralNotes FROM Hotels;

    All of the information is self contained on this one form. The only item I have which doesn't appear affected by things is a subform used to track distance from the hotel to the venue.

    As far as inner joins are concerned I don't have any in this individual form. However, if referential integrity was enforced on the overall relationship level could this be possibly be preventing some records from pulling while allowing others in?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Simple SELECT query. All records matching filter criteria should be retrieved. Referential integrity should not have impact.

    If you want to provide db for analysis, follow instructions at bottom of my post.

    Advise not to use spaces or special characters/punctuation (underscore is exception) in naming convention.

    The table structure is not truly normalized - as indicated by the multiple yes/no fields but don't think that is part of this issue.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    TeamTraveler is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    May 2015
    Posts
    18
    June,

    Thank you for reviewing. I have attached my file.

    Matt
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Relationships getting 'spider-webby', be careful - might review http://www.codeproject.com/Articles/...atabase-Design


    [Hotel Dist to Venue] should not have both ID and descriptive fields for hotels and venues - just one or the other (recommend IDs). Then do linking and searching on IDs.


    Not seeing the described issue. Hotels has 261 records. All 261 records retrieved by the form. The combobox does 'go to' selected hotel.


    Suggest you apply ORDER BY clause in the combobox RowSource sql.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Can you give us an example of what selection doesn't retrieve all related records?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    TeamTraveler is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    May 2015
    Posts
    18
    Quote Originally Posted by Missinglinq View Post
    Can you give us an example of what selection doesn't retrieve all related records?

    Linq ;0)>
    June, thanks for the time in review and your thoughts. Yes, you are correct - all records in table pull into the form.

    However, if you go to the Hotel Input form, and open the combo box, when the top three selections are made, they DO pull the record into the form. The next three records in a row for Birmingham - DON'T pull in. Both Calera hotels pull in. The first two Hoover hotels do NOT, but the next three do. This is what I'm seeing.

    When I look at the records to possibly identify what some records have that others don't, I couldn't identify the issue.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Okay, that is good to know. Apparently I did not pick one of the problem records. Cause of issue is the apostrophe in the hotel names. Apostrophes and quote marks within SQL are an issue because of their special purposes. The search criteria in the SearchForRecord method is like the WHERE clause of an SQL statement and follows the same rules. Apostrophe and quote marks must be doubled within the string so as to be recognized as text and not special character (this is referred to as 'escaping' special characters). I don't use macros so I converted to VBA.

    DoCmd.SearchForRecord , "", acFirst, "[HotelName]='" & Replace(Screen.ActiveControl, "'", "''") & "'"

    There would not be an issue if you did search on HotelID. If you don't save the HotelID as foreign key then it serves no purpose to designate it as primary key. Since you save HotelName as foreign key, it should be designated primary key.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    TeamTraveler is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    May 2015
    Posts
    18
    Quote Originally Posted by June7 View Post
    Okay, that is good to know. Apparently I did not pick one of the problem records. Cause of issue is the apostrophe in the hotel names. Apostrophes and quote marks within SQL are an issue because of their special purposes. The search criteria in the SearchForRecord method is like the WHERE clause of an SQL statement and follows the same rules. Apostrophe and quote marks must be doubled within the string so as to be recognized as text and not special character (this is referred to as 'escaping' special characters). I don't use macros so I converted to VBA.

    DoCmd.SearchForRecord , "", acFirst, "[HotelName]='" & Replace(Screen.ActiveControl, "'", "''") & "'"

    There would not be an issue if you did search on HotelID. If you don't save the HotelID as foreign key then it serves no purpose to designate it as primary key. Since you save HotelName as foreign key, it should be designated primary key.
    This worked like a charm! Thank you very much, June.

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

Similar Threads

  1. Query doesn't pull all data from tables
    By CARANJ in forum Queries
    Replies: 5
    Last Post: 02-12-2014, 02:02 PM
  2. Replies: 2
    Last Post: 01-28-2014, 06:14 AM
  3. Replies: 3
    Last Post: 11-25-2013, 08:23 PM
  4. Replies: 3
    Last Post: 12-16-2011, 02:37 PM
  5. Query can't pull parameter from combobox
    By testsubject in forum Queries
    Replies: 3
    Last Post: 03-08-2011, 11:26 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