Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / February 2008

Tip: Looking for answers? Try searching our database.

Table Linking

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MJM2244 - 06 Feb 2008 13:54 GMT
I'll start out the question with what I'm trying to accomplish.  Basically,
I've created a form that populates data into a table (lets call it table 1).  
I want to be able to reference this table against a master table (call it
table 2) and return the matching results.  The form has a command button that
runs a query that links these two tables and returns the resulting matches.  
The problem I am having is that if a user wanted to leave one of the fields
blank on the populating form the query will not return anything.  So lets say
the form asks for State, City, County and Zip Code all of these then populate
the corresponding column in Table 1.  If the user only wanted to enter the
County and Zip Code fields how can I get the query to still return these
matches.  I know the query is then saying the State field in Table 1 is blank
there are no blank State fields in Table 2 so return nothing.  Is there some
kind of wildcard character or join property that can still link the two
fields from the tables if one of the fields in Table 1 is blank.

Thank You
Michel Walsh - 07 Feb 2008 15:50 GMT
You may either add an OR FieldName IS NULL to make something like:

(State = FORMS!FormName!Sate OR  State IS NULL) AND (City =
FORMS!FormName!city OR City IS NULL )  AND ( ... )

in SQL view of your query of your query,

either produces the SQL statement with the not empty criteria:

Dim str AS String
   str= " true  "
   if( 0 <> len( Me.State  & vbNullString) ) then  str = str & "   AND
(State = FORMS!FormName!Sate OR  State IS NULL)   "
   if( 0 <> len( Me.City & vbNullString)) then str= str & "  AND (City =
FORMS!FormName!city OR City IS NULL )   "
   ...

and use the string as criteria either directly, either appending the other
SQL parts to it to make a complete SQL statement.

Hoping it may help,
Vanderghast, Access MVP

> I'll start out the question with what I'm trying to accomplish.
> Basically,
[quoted text clipped - 21 lines]
>
> Thank You
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.