Results 1 to 5 of 5
  1. #1
    dwil98059 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    3

    Question Query based on incompatible string lengths


    I have two disparate data sources that each contain an Employee ID field that I need to perform a join with. One data source enforces a 6 character length, the other data source doesn't. Because of this, Employee IDs in one system are 6 characters long, with preceeding zeros, but the other data source isn't (e.g. 0000405 in system one, but 405 in system two). Even though this is the same employee, I can't figure out how to join the two datasets.

    Any ideas?

  2. #2
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    Something like this (assuming the employer2 Employee ID is currently formatted like '0000405'):
    select
    E1.*
    ,E2.*
    from Employer1 E1
    InnerJoin Employer2 E2
    on E1.EmpID = CLng(E2.EmpID)

  3. #3
    dwil98059 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    3

    Exclamation

    Any chance of an MS-Access built-in function performing the same thing? This is just a small database, performing a query to pass data out to an Excel spreadsheet. If possible, I'd like to do the join in the MS-Access query builder and not have to build code.

    Thanks

  4. #4
    dwil98059 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    3
    Thanks for your reply to my MS-Access query question. Can you think of any built-in function within Access that would do something similar? If possible, I want to use the Access query builder to complete this project -- our typical users won't be able to navigate VBA code! Thanks.

  5. #5
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    A quick thought...

    Create a query using the query builder for the data source with “000405” as the employeeID

    Create another query for the data source with “405” as the employeeID

    In each of the two queries add a NEW column, RevisedempID: ([employeeID]+100000)

    This assumes that there is at least 1 preceeding zero in the employeeID field in each of the rows in the table using 6 digits as the employeeID

    Then try to join the two queries based on the RevisedempID

    I have not tested this yet, it’s just an idea…

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

Similar Threads

  1. close form based on string
    By eww in forum Programming
    Replies: 3
    Last Post: 03-18-2011, 01:50 PM
  2. Split a string for use as query parameters.
    By Hobbes29 in forum Forms
    Replies: 3
    Last Post: 06-27-2010, 04:39 PM
  3. Limiting fields to certain lengths......
    By softspoken in forum Access
    Replies: 5
    Last Post: 04-20-2010, 12:32 PM
  4. Replies: 1
    Last Post: 03-22-2010, 03:37 PM
  5. Replies: 0
    Last Post: 12-05-2005, 04:09 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