473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DLookup matching select characters from one table to select characters in another

newnewbie
I need help with a query where I am trying to match and display the value (First 18 characters of it) in one table that matches the first 18 characters of the field value in another table. Tables are not linked.

Tables, fields and data examples:
Table # 1 Name: Claims
Filed Name: Name
Field Value example: 2006120800011CLT108.TIF#http://fl-jax-sharp/sites%2Fclaims%2FClaims%2F2006%...and it goes on

Table # 2 Name: Raw Data
Field Name: Batch
Filed Value example: 2006120800011CLT108.TIF

Expand|Select|Wrap|Line Numbers
  1.  DLookup ("[Batch]", "[Raw Data]", "[First 18 characters of Batch Field]"="[First 18 characters of Name Field]", "[Name]", "[Claims]"
I don't know how to write out the "[First 18 characters of Name Field]"...maybe I even need to use a different function altogether....

Please advise,
Thanks!
Dec 20 '06 #1
3 2137
ADezii
8,834 Expert 8TB
I need help with a query where I am trying to match and display the value (First 18 characters of it) in one table that matches the first 18 characters of the field value in another table. Tables are not linked.

Tables, fields and data examples:
Table # 1 Name: Claims
Filed Name: Name
Field Value example: 2006120800011CLT108.TIF#http://fl-jax-sharp/sites%2Fclaims%2FClaims%2F2006%...and it goes on

Table # 2 Name: Raw Data
Field Name: Batch
Filed Value example: 2006120800011CLT108.TIF

Expand|Select|Wrap|Line Numbers
  1.  DLookup ("[Batch]", "[Raw Data]", "[First 18 characters of Batch Field]"="[First 18 characters of Name Field]", "[Name]", "[Claims]"
I don't know how to write out the "[First 18 characters of Name Field]"...maybe I even need to use a different function altogether....

Please advise,
Thanks!
'This should solve your problem nicely:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As Database, MyRS As Recordset
  2. Dim MyDB_2 As Database, MyRS_2 As Recordset
  3.  
  4. Set MyDB = CurrentDb()
  5. Set MyDB_2 = CurrentDb()
  6.  
  7. Set MyRS = MyDB.OpenRecordset("Claims")
  8. Set MyRS_2 = MyDB_2.OpenRecordset("Raw Data")
  9.  
  10. Debug.Print MyRS.RecordCount
  11. Debug.Print MyRS_2.RecordCount
  12.  
  13. Do While Not MyRS_2.EOF
  14.   Do While Not MyRS.EOF
  15.    Debug.Print MyRS_2![Batch] & " <==> " & MyRS![Name]
  16.     If Trim(Left(MyRS_2![Batch], 18)) = Trim(Left(MyRS![Name], 18)) Then
  17.       Debug.Print "Found a Match at Batch Number: " & MyRS_2![Batch]
  18.         Exit Sub
  19.     End If
  20.     MyRS.MoveNext
  21.   Loop
  22.   MyRS.MoveFirst
  23.   MyRS_2.MoveNext
  24. Loop
  25.  
  26. MyRS.Close
  27. MyRS_2.Close
Dec 21 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
ADezii's answer is correct. However, if you just need a basic query. As long as there aren't too many records the following should work.

Expand|Select|Wrap|Line Numbers
  1. SELECT Left([RawData].[Batch], 18) As Batch18
  2. FROM Claims, RawData
  3. WHERE Left([RawData].[Batch], 18) Like Left([Claims].[Name], 18)
  4. GROUP BY Left([RawData].[Batch], 18);
  5.  
Mary
Dec 21 '06 #3
ADezii,
Forgive me my ignorance, but if I only knew where to put the code you wrote for me. I know the question sounds dumb, but I am not a programmer and I just do basic queries in the design view...So if you could tell me where I insert the Code...

Thanks...



'This should solve your problem nicely:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As Database, MyRS As Recordset
  2. Dim MyDB_2 As Database, MyRS_2 As Recordset
  3.  
  4. Set MyDB = CurrentDb()
  5. Set MyDB_2 = CurrentDb()
  6.  
  7. Set MyRS = MyDB.OpenRecordset("Claims")
  8. Set MyRS_2 = MyDB_2.OpenRecordset("Raw Data")
  9.  
  10. Debug.Print MyRS.RecordCount
  11. Debug.Print MyRS_2.RecordCount
  12.  
  13. Do While Not MyRS_2.EOF
  14.   Do While Not MyRS.EOF
  15.    Debug.Print MyRS_2![Batch] & " <==> " & MyRS![Name]
  16.     If Trim(Left(MyRS_2![Batch], 18)) = Trim(Left(MyRS![Name], 18)) Then
  17.       Debug.Print "Found a Match at Batch Number: " & MyRS_2![Batch]
  18.         Exit Sub
  19.     End If
  20.     MyRS.MoveNext
  21.   Loop
  22.   MyRS.MoveFirst
  23.   MyRS_2.MoveNext
  24. Loop
  25.  
  26. MyRS.Close
  27. MyRS_2.Close
Dec 21 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one...
5
by: Kalvin Schroder | last post by:
I am fairly new to Access, and am trying to put together an invoice form. The main form in called InvoiceDetailFm. Source is the table InvoiceDetail and has invoice number, saleman, and CustID as...
3
by: DFS | last post by:
FYI, Using DLookup("ResultsField","Pass-thru query") consumes 2 SEQUENCE numbers each time it's called. Anyone know why?
4
by: basstwo | last post by:
I have a field with a serial number in it. I want to use Mid to extract the 4th and 5th characters, use them to lookup a value on a small lookup table, and use the info from that table to fill in...
2
by: Jon Lapham | last post by:
I have a table that stores TEXT information. I need query this table to find *exact* matches to the TEXT... no regular expressions, no LIKE queries, etc. The TEXT could be from 1 to 10000+...
11
by: MLH | last post by:
DLookup("", "tblPreliminaryVINs", "=Forms!frmVINODO!SerialNum") is giving me a Type Mismatch error. That's confusing to me and I don't know how to circumvent it. The field in...
21
by: Thelma Lubkin | last post by:
I would like my DLookup criteria to say this: Trim(fieldX) = strVar: myVar = _ DLookup("someField", "someTable", "Trim(fieldX) = '" & strVar & '") I don't believe that this will work, and I...
5
by: favor08 | last post by:
I have a database and I am using a function that captures the shortname and displays it on the mainMenu screen. What I want to do is filter the information on the "past due" screen based on the...
3
gcoaster
by: gcoaster | last post by:
Hello! I am having problem with DLookup Function DLookup looks on form, and finds the combobox = cboFullName and then compares it to the column clientID in tblCLIENTS table. if they match,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.