G
Guest
Hi all..
Here is what I have:
I have a query that is running a search form. The query is made up of three
tables:
1.tblMain
2.tblSpouse
3.tblChildren
When I have the query looking at just tables 1 and 2 it works fine. But when
I put in table three my query doesn't work correctly.
Here is what it is doing. On my search form I have a main window that lists
all of the entries into the database. I then have two subforms one for spouse
and one for children. The spouse now shows this:
Last Name
Washington
Washington
Washington
Washington
Washington
Washington
First Name
Janine
Janine
Janine
Sally
Sally
Sally
(two wives, 1 current, 1 past)
And the children show this
Last Name
Washington
Washington
Washington
Washington
Washington
Washington
First Name
David
David
Mines
Mines
Foy
Foy
And the one entry that does not have any children is no longer showing up in
the main window with the other entries.
Here is the sql of the query:
SELECT tblMain.EntryNumber, tblMain.DriversLicNumber, tblMain.EmpNumber,
tblMain.FName, tblMain.LName, tblMain.MInitial, tblSpouse.LName,
tblSpouse.FName, tblSpouse.MInitial, tblSpouse.DriversLicNumber,
tblChildren.LName, tblChildren.FName, tblChildren.MInitial,
tblChildren.DriversLicNumber, *
FROM (tblMain INNER JOIN tblChildren ON tblMain.EntryNumber =
tblChildren.EntryNumber) INNER JOIN tblSpouse ON tblMain.EntryNumber =
tblSpouse.EntryNumber
WHERE ((([tblMain]![EntryNumber] And [tblSpouse]![EntryNumber] And
[tblChildren]![EntryNumber]) Like "*" & [Forms]![frmSearch]![Search2] & "*"))
OR (((tblMain.EmpNumber) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblMain.FName) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblMain.LName) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblMain.MInitial) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblSpouse.LName) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblSpouse.FName) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblSpouse.EntryNumber) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblSpouse.DriversLicNumber) Like "*" & [Forms]![frmSearch]![Search2] &
"*")) OR (((tblMain.DriversLicNumber) Like "*" &
[Forms]![frmSearch]![Search2] & "*")) OR (((tblSpouse.MInitial) Like "*" &
[Forms]![frmSearch]![Search2] & "*")) OR (((tblChildren.LName) Like "*" &
[Forms]![frmSearch]![Search2] & "*")) OR (((tblChildren.FName) Like "*" &
[Forms]![frmSearch]![Search2] & "*")) OR (((tblChildren.DriversLicNumber)
Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR (((tblChildren.MInitial)
Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblChildren.EntryNumber) Like "*" & [Forms]![frmSearch]![Search2] & "*"))
ORDER BY tblMain.EntryNumber, tblSpouse.EntryNumber, tblChildren.EntryNumber;
Sorry for the long post but I wanted to make sure most if not everything was
covered.
Thanks
R~
Here is what I have:
I have a query that is running a search form. The query is made up of three
tables:
1.tblMain
2.tblSpouse
3.tblChildren
When I have the query looking at just tables 1 and 2 it works fine. But when
I put in table three my query doesn't work correctly.
Here is what it is doing. On my search form I have a main window that lists
all of the entries into the database. I then have two subforms one for spouse
and one for children. The spouse now shows this:
Last Name
Washington
Washington
Washington
Washington
Washington
Washington
First Name
Janine
Janine
Janine
Sally
Sally
Sally
(two wives, 1 current, 1 past)
And the children show this
Last Name
Washington
Washington
Washington
Washington
Washington
Washington
First Name
David
David
Mines
Mines
Foy
Foy
And the one entry that does not have any children is no longer showing up in
the main window with the other entries.
Here is the sql of the query:
SELECT tblMain.EntryNumber, tblMain.DriversLicNumber, tblMain.EmpNumber,
tblMain.FName, tblMain.LName, tblMain.MInitial, tblSpouse.LName,
tblSpouse.FName, tblSpouse.MInitial, tblSpouse.DriversLicNumber,
tblChildren.LName, tblChildren.FName, tblChildren.MInitial,
tblChildren.DriversLicNumber, *
FROM (tblMain INNER JOIN tblChildren ON tblMain.EntryNumber =
tblChildren.EntryNumber) INNER JOIN tblSpouse ON tblMain.EntryNumber =
tblSpouse.EntryNumber
WHERE ((([tblMain]![EntryNumber] And [tblSpouse]![EntryNumber] And
[tblChildren]![EntryNumber]) Like "*" & [Forms]![frmSearch]![Search2] & "*"))
OR (((tblMain.EmpNumber) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblMain.FName) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblMain.LName) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblMain.MInitial) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblSpouse.LName) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblSpouse.FName) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblSpouse.EntryNumber) Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblSpouse.DriversLicNumber) Like "*" & [Forms]![frmSearch]![Search2] &
"*")) OR (((tblMain.DriversLicNumber) Like "*" &
[Forms]![frmSearch]![Search2] & "*")) OR (((tblSpouse.MInitial) Like "*" &
[Forms]![frmSearch]![Search2] & "*")) OR (((tblChildren.LName) Like "*" &
[Forms]![frmSearch]![Search2] & "*")) OR (((tblChildren.FName) Like "*" &
[Forms]![frmSearch]![Search2] & "*")) OR (((tblChildren.DriversLicNumber)
Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR (((tblChildren.MInitial)
Like "*" & [Forms]![frmSearch]![Search2] & "*")) OR
(((tblChildren.EntryNumber) Like "*" & [Forms]![frmSearch]![Search2] & "*"))
ORDER BY tblMain.EntryNumber, tblSpouse.EntryNumber, tblChildren.EntryNumber;
Sorry for the long post but I wanted to make sure most if not everything was
covered.
Thanks
R~