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 - 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!
3 2137
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 - 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: - Dim MyDB As Database, MyRS As Recordset
-
Dim MyDB_2 As Database, MyRS_2 As Recordset
-
-
Set MyDB = CurrentDb()
-
Set MyDB_2 = CurrentDb()
-
-
Set MyRS = MyDB.OpenRecordset("Claims")
-
Set MyRS_2 = MyDB_2.OpenRecordset("Raw Data")
-
-
Debug.Print MyRS.RecordCount
-
Debug.Print MyRS_2.RecordCount
-
-
Do While Not MyRS_2.EOF
-
Do While Not MyRS.EOF
-
Debug.Print MyRS_2![Batch] & " <==> " & MyRS![Name]
-
If Trim(Left(MyRS_2![Batch], 18)) = Trim(Left(MyRS![Name], 18)) Then
-
Debug.Print "Found a Match at Batch Number: " & MyRS_2![Batch]
-
Exit Sub
-
End If
-
MyRS.MoveNext
-
Loop
-
MyRS.MoveFirst
-
MyRS_2.MoveNext
-
Loop
-
-
MyRS.Close
-
MyRS_2.Close
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. -
SELECT Left([RawData].[Batch], 18) As Batch18
-
FROM Claims, RawData
-
WHERE Left([RawData].[Batch], 18) Like Left([Claims].[Name], 18)
-
GROUP BY Left([RawData].[Batch], 18);
-
Mary
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: - Dim MyDB As Database, MyRS As Recordset
-
Dim MyDB_2 As Database, MyRS_2 As Recordset
-
-
Set MyDB = CurrentDb()
-
Set MyDB_2 = CurrentDb()
-
-
Set MyRS = MyDB.OpenRecordset("Claims")
-
Set MyRS_2 = MyDB_2.OpenRecordset("Raw Data")
-
-
Debug.Print MyRS.RecordCount
-
Debug.Print MyRS_2.RecordCount
-
-
Do While Not MyRS_2.EOF
-
Do While Not MyRS.EOF
-
Debug.Print MyRS_2![Batch] & " <==> " & MyRS![Name]
-
If Trim(Left(MyRS_2![Batch], 18)) = Trim(Left(MyRS![Name], 18)) Then
-
Debug.Print "Found a Match at Batch Number: " & MyRS_2![Batch]
-
Exit Sub
-
End If
-
MyRS.MoveNext
-
Loop
-
MyRS.MoveFirst
-
MyRS_2.MoveNext
-
Loop
-
-
MyRS.Close
-
MyRS_2.Close
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
by: DFS |
last post by:
FYI,
Using DLookup("ResultsField","Pass-thru query") consumes 2 SEQUENCE numbers
each time it's called.
Anyone know why?
|
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...
|
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+...
|
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...
|
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...
|
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...
|
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,...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |