+ Reply to Thread
Results 1 to 12 of 12

Determining if Excel values equal Access table values

  1. #1
    Registered User
    Join Date
    12-09-2013
    Location
    Bristol, Connecticut
    MS-Off Ver
    Excel 2007
    Posts
    7

    Question Determining if Excel values equal Access table values

    One aspect of my Excel-based project involves comparing the operator-entered part number (in Excel) to a predetermined list of part numbers in one column of an Access database table. Right now, my program is telling me that every part number entered in the spreadsheet (50+) does not match any part number in the database, which I've verified to be incorrect. I've checked that both the spreadsheet part number and the database part number are of the string datatype. To the best of my knowledge, my looping logic seems valid and robust. To the best of my knowledge, there are no hidden characters in either the database cells or in the spreadsheet cells causing this apparent mismatch. I'm completely stumped at this point as to why my program doesn't detect any matches between the spreadsheet and the database table. Below is the Sub containing the code for checking that the part numbers match:

    Please Login or Register  to view this content.
    I apologize if this is posted in the wrong thread section. This issue seems to be a hybrid issue between Excel and Access with (to me) more of the issue on the Access end.

    Thanks for your help.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Determining if Excel cell values equal Access database table values

    Look at this link and see if it does what you trying to achieve.

    http://datapigtechnologies.com/blog/...omment-page-2/
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    12-09-2013
    Location
    Bristol, Connecticut
    MS-Off Ver
    Excel 2007
    Posts
    7

    Question Re: Determining if Excel cell values equal Access database table values

    I don't think I want to make a query in Access though, although I'm not fully certain. Unfortunately, I'm quite the Access newbie. At the very least, I don't think running a parameter query is ideal for my situation. I don't want the user to be prompted to type in a part number and then have Access search through the table to see if there is a match. In my case, the user enters all the data beforehand into Excel and the Excel program is then supposed to check those entered part numbers against the existing part numbers in Access once the program is running. Perhaps it could work if, instead of prompting the user for a part number each time, the query instead took each entry already entered in Excel as the parameter? Would I then still be using a parameter query? If not, doesn't the SQL statement in my code above already create a select query against which I should be able to then compare my excel values? Basically, all I need to do is compare each cell in one column in Excel to each entry in one field of an Access table (1:many). Can it be done without Access queries or with a Select query instead? Thanks for your help.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Determining if Excel values equal Access table values

    A couple of things

    * Your sql isn't being executed, it should look like this:
    Please Login or Register  to view this content.
    * SQL isn't case sensitive, whereas Excel is, you're also not removing trailing spaces from the Access field so you may need to do:
    Please Login or Register  to view this content.
    * Have a look at the filter command on the recordset, it may be faster

    *I've found for things like this, it's sometimes faster to stick the recordset into an array and iterate that

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Determining if Excel values equal Access table values

    I am curious about the reason for Distinct in your SQL statement. What happens if you remove Distinct? Does it change the results? Would each part number be listed only one time in the table? If so, then Distinct is not needed and it appears that you are only looking for the one field to be returned.

  6. #6
    Registered User
    Join Date
    12-09-2013
    Location
    Bristol, Connecticut
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Determining if Excel values equal Access table values

    Thanks for the responses, but unfortunately none of the aforementioned solutions have fixed the issue with my program. I am still not getting any part number matches.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Determining if Excel values equal Access table values

    It may be time to upload a sample database and sample worksheet for analysis. Seeing an actual file(s) often makes it easier to provide a workable solution.

  8. #8
    Registered User
    Join Date
    12-09-2013
    Location
    Bristol, Connecticut
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Determining if Excel values equal Access table values

    OK, I can upload my project and my database if that's appropriate. How would I go about doing that? BTW, instead of trying to read into a program database, I've simplified things by now having the program read from a database I created. Only a couple lines of code were minutely changed. Thanks.

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,879

    Re: Determining if Excel values equal Access table values

    Make sure that both files are only representative of the entire file. For both files desensitize for confidential information (change to dummy info).

    For the db, run a compact and repair. Zip the db file then. The forum will only accept zipped files for Access files.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  10. #10
    Registered User
    Join Date
    12-09-2013
    Location
    Bristol, Connecticut
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Determining if Excel values equal Access table values

    P&Q Tracking Rev 7.xlsm
    P&Q_Tracking_Data_Storage.zip

    Ok great, attached are the zipped Access database and the Excel program. There is no confidential information in either application. For the Excel file, the applicable code is found in Module1 under the sub CheckPN(). Thanks for your help. Please let me know if you have any further questions.

  11. #11
    Registered User
    Join Date
    12-09-2013
    Location
    Bristol, Connecticut
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Determining if Excel values equal Access table values

    Any ideas as to what specifically could be causing the error?

    Thanks for your help.

  12. #12
    Registered User
    Join Date
    12-09-2013
    Location
    Bristol, Connecticut
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Determining if Excel values equal Access table values

    I found my problem at long last. I needed to add .MoveFirst after my For loop declaration and I needed to set my Do Loop condition = True. Now my code loops correctly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Populate values in Excel worksheet from Access table
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-01-2014, 07:47 AM
  2. Replies: 0
    Last Post: 07-23-2010, 01:41 PM
  3. To move the values from excel userform to Access table using vba
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2009, 09:47 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1