G
Guest
I have a form/sub form set-up whereby a user can enter search criteria into
one of any 12 fields. These fields are either text or pull down menus. I
have tried every kind of And/Or combination, but am unable to get an accurate
return. I believe this has to do with the fact that four of the fields to be
searched do not always have data to query on. These fields in the table are
not required to be completed and therefore have a null value.
Using Like [Forms]![frmMain]![Entity] Or Like "*" does not return records
that may have a null value for "Entity"
Using Like [Forms]![frmMain]![Entity] Or Is Null does not return records
that might have values that match other criteria entered
Using Like [Forms]![frmMain]![Entity] Or Like "*" Or Is Null does not return
any records
I have searched other sites and it is suggested that with this many
criterion I should ues VBA to run the query. I have followed the steps
listed and here is my code, however when I tried to view it I get an error
"Characters found after the end of SQL Statement". Help - please!
SELECT tblFiles.[File ID], tblFiles.Entity, tblFiles.Location,
tblFiles.[Record Series], tblFiles.[Document Type], tblFiles.[File Name],
tblFiles.[File Description], tblFiles.[Entered By], tblFiles.[Creation Date],
tblFiles.[Project Number], tblFiles.[Project Name], tblFiles.[Project Manager]
FROM tblFiles; WHERE (((FileID)=[Forms]![frmMain]![FileID] Or
(IsNull([Forms]![frmMain]![FileID]))) AND
((Entity)=[Forms]![frmMain]![Entity] Or (IsNull([Forms]![frmMain]![Entity])))
AND ((Location)=[Forms]![frmMain]![Location] Or
(IsNull([Forms]![frmMain]![Location]))) AND ((Record
Series)=[Forms]![frmMain]![RecordSeries] Or
(IsNull([Forms]![frmMain]![RecordSeries]))) AND ((Document
Type)=[Forms]![frmMain]![DocumentType] Or
(IsNull([Forms]![frmMain]![DocumentType]))) AND ((File
Name)=[Forms]![frmMain]![FileName] Or (IsNull([Forms]![frmMain]![FileName])))
AND ((File Description)=[Forms]![frmMain]![FileDescription] Or
(IsNull([Forms]![frmMain]![FileDescription]))) AND ((Entered
By)=[Forms]![frmMain]![EnteredBy] Or (IsNull([Forms]![frmMain]![EnteredBy])))
AND ((Creation Date)=[Forms]![frmMain]![CreationDate] Or
(IsNull([Forms]![frmMain]![CreationDate]))) AND ((Project
Number)=[Forms]![frmMain]![ProjectNumber] Or
(IsNull([Forms]![frmMain]![ProjectNumber]))) AND ((Project
Name)=[Forms]![frmMain]![ProjectName] Or
(IsNull([Forms]![frmMain]![ProjectName]))) AND ((Project
Manager)=[Forms]![frmMain]![ProjectManager] Or
(IsNull([Forms]![frmMain]![ProjectManager]))));
one of any 12 fields. These fields are either text or pull down menus. I
have tried every kind of And/Or combination, but am unable to get an accurate
return. I believe this has to do with the fact that four of the fields to be
searched do not always have data to query on. These fields in the table are
not required to be completed and therefore have a null value.
Using Like [Forms]![frmMain]![Entity] Or Like "*" does not return records
that may have a null value for "Entity"
Using Like [Forms]![frmMain]![Entity] Or Is Null does not return records
that might have values that match other criteria entered
Using Like [Forms]![frmMain]![Entity] Or Like "*" Or Is Null does not return
any records
I have searched other sites and it is suggested that with this many
criterion I should ues VBA to run the query. I have followed the steps
listed and here is my code, however when I tried to view it I get an error
"Characters found after the end of SQL Statement". Help - please!
SELECT tblFiles.[File ID], tblFiles.Entity, tblFiles.Location,
tblFiles.[Record Series], tblFiles.[Document Type], tblFiles.[File Name],
tblFiles.[File Description], tblFiles.[Entered By], tblFiles.[Creation Date],
tblFiles.[Project Number], tblFiles.[Project Name], tblFiles.[Project Manager]
FROM tblFiles; WHERE (((FileID)=[Forms]![frmMain]![FileID] Or
(IsNull([Forms]![frmMain]![FileID]))) AND
((Entity)=[Forms]![frmMain]![Entity] Or (IsNull([Forms]![frmMain]![Entity])))
AND ((Location)=[Forms]![frmMain]![Location] Or
(IsNull([Forms]![frmMain]![Location]))) AND ((Record
Series)=[Forms]![frmMain]![RecordSeries] Or
(IsNull([Forms]![frmMain]![RecordSeries]))) AND ((Document
Type)=[Forms]![frmMain]![DocumentType] Or
(IsNull([Forms]![frmMain]![DocumentType]))) AND ((File
Name)=[Forms]![frmMain]![FileName] Or (IsNull([Forms]![frmMain]![FileName])))
AND ((File Description)=[Forms]![frmMain]![FileDescription] Or
(IsNull([Forms]![frmMain]![FileDescription]))) AND ((Entered
By)=[Forms]![frmMain]![EnteredBy] Or (IsNull([Forms]![frmMain]![EnteredBy])))
AND ((Creation Date)=[Forms]![frmMain]![CreationDate] Or
(IsNull([Forms]![frmMain]![CreationDate]))) AND ((Project
Number)=[Forms]![frmMain]![ProjectNumber] Or
(IsNull([Forms]![frmMain]![ProjectNumber]))) AND ((Project
Name)=[Forms]![frmMain]![ProjectName] Or
(IsNull([Forms]![frmMain]![ProjectName]))) AND ((Project
Manager)=[Forms]![frmMain]![ProjectManager] Or
(IsNull([Forms]![frmMain]![ProjectManager]))));