Results 1 to 13 of 13
  1. #1
    Darkladymelz is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    43

    Parameter Values

    I have created 3 parameter values within one query but I only require one out of the 3 to be answered in order to achieve my results. The other two could be filled out or left blank.

    I keep finding that this is pulling up blank results although I know I am putting in correct information. (answering 1 but leaving other 2 blank). Is there another way I should be trying or an expression I should be using?



    Thank you for your help in advance.

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Post the SQL for your query.

  3. #3
    Darkladymelz is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    43
    SELECT [Landlord Details].[Landlord Ref], [Property Details].[Property Ref], [Property Details].[Property Address], [Property Details].County, [Property Details].[Post Code], [Property Details].[Property Type], [Property Details].Bedrooms, [Property Details].Floor, [Property Details].[Start Date], [Property Details].[End Date], [Property Details].Rent, [Property Details].[Guaranteed Rent], [Property Details].Supplier, [Landlord Details].Firstname, [Landlord Details].Surname, [Landlord Details].[Contact Address], [Landlord Details].[Home No], [Landlord Details].[Work No], [Landlord Details].[Mobile No], [Landlord Details].[Email Address]
    FROM [Landlord Details] INNER JOIN [Property Details] ON [Landlord Details].[Landlord Ref] = [Property Details].[Landlord Ref]
    WHERE ((([Landlord Details].[Landlord Ref])=[Enter Landlord Ref]) AND (([Landlord Details].Firstname)=[Enter Landlord Name]) AND (([Landlord Details].Surname)=[Enter Landlord Surname]));

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Your parameters are joined by AND which means
    ((([Landlord Details].[Landlord Ref])=[Enter Landlord Ref]) AND (([Landlord Details].Firstname)=[Enter Landlord Name]) AND (([Landlord Details].Surname)=[Enter Landlord Surname]));

    If you leave 1 or 2 empty, you are asking for empty (either NULL or zero length string values in your data).

    What exactly do you want to search for -exact matches, first few characters????

    You may want to review the LIKE operator
    http://office.microsoft.com/en-us/ac...001231490.aspx

  5. #5
    Darkladymelz is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    43
    I want to search for exact matches only.

    What would I replace the AND with?

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Try this:

    (
    [Landlord Details].[Landlord Ref]=[Enter Landlord Ref]) OR
    ISNull([Landlord Details].[Landlord Ref]) OR [Landlord Details].[Landlord Ref]='')
    AND
    ([Landlord Details].Firstname=[Enter Landlord Name] OR
    IsNull(
    [Landlord Details].Firstname) OR [Landlord Details].Firstname ='')
    AND
    ([Landlord Details].Surname=[Enter Landlord Surname] OR
    IsNULL([Landlord Details].Surname) OR [Landlord Details].Surname='' )

  7. #7
    Darkladymelz is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    43
    Thank you.

    I have tried this. Parameter Value boxes are appearing but results are not showing for "Landlord Ref" or "Firstname". The only results that show are for Surname.

    Please let me know if I have gone wrong somewhere. Here is the SQL:

    SELECT [Landlord Details].[Landlord Ref], [Property Details].[Property Ref], [Property Details].[Property Address], [Property Details].County, [Property Details].[Post Code], [Property Details].[Property Type], [Property Details].Bedrooms, [Property Details].Floor, [Property Details].[Start Date], [Property Details].[End Date], [Property Details].Rent, [Property Details].[Guaranteed Rent], [Property Details].Supplier, [Landlord Details].Firstname, [Landlord Details].Surname, [Landlord Details].[Contact Address], [Landlord Details].[Home No], [Landlord Details].[Work No], [Landlord Details].[Mobile No], [Landlord Details].[Email Address]
    FROM [Landlord Details] INNER JOIN [Property Details] ON [Landlord Details].[Landlord Ref] = [Property Details].[Landlord Ref]
    WHERE ((([Landlord Details].[Landlord Ref])=[Enter Landlord Ref:]) OR IsNull ([Landlord Details].[Landlord Ref]) OR [Landlord Details].[Landlord Ref]=[Enter Landlord Ref:]) AND (([Landlord Details].Firstname)=[Enter Firstname:]) OR IsNull ([Landlord Details].Firstname) OR [Landlord Details].Firstname =[Enter Firstname:] AND (([Landlord Details].Surname)=[Enter Surname:]) OR IsNull ([Landlord Details].Surname) OR [Landlord Details].Surname=[Enter Surname:];

    Thank you

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I played with the brackets and removed the second request for the parameter

    SELECT [Landlord Details].[Landlord Ref], [Property Details].[Property Ref], [Property Details].[Property Address], [Property Details].County, [Property Details].[Post Code], [Property Details].[Property Type], [Property Details].Bedrooms, [Property Details].Floor, [Property Details].[Start Date], [Property Details].[End Date], [Property Details].Rent, [Property Details].[Guaranteed Rent], [Property Details].Supplier, [Landlord Details].Firstname, [Landlord Details].Surname, [Landlord Details].[Contact Address], [Landlord Details].[Home No], [Landlord Details].[Work No], [Landlord Details].[Mobile No], [Landlord Details].[Email Address]
    FROM [Landlord Details] INNER JOIN [Property Details] ON [Landlord Details].[Landlord Ref] = [Property Details].[Landlord Ref]
    WHERE
    (
    (([Landlord Details].[Landlord Ref])=[Enter Landlord Ref:]) OR
    IsNull ([Landlord Details].[Landlord Ref]) OR
    [Landlord Details].[Landlord Ref]=''
    )
    AND
    (
    (([Landlord Details].Firstname)=[Enter Firstname:]) OR
    IsNull ([Landlord Details].Firstname) OR
    [Landlord Details].Firstname =''
    )
    AND
    (
    (([Landlord Details].Surname)=[Enter Surname:]) OR
    IsNull ([Landlord Details].Surname) OR
    [Landlord Details].Surname= ''
    );

  9. #9
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Here's another version. It is a parameters query. The parameters are slightly different(spelling) but should work.

    Create a new query, go to sql view and paste this into the window.
    PARAMETERS
    EnterLandlordRef string,
    EnterFirstName string,
    EnterSurname string;
    SELECT [Landlord Details].[Landlord Ref], [Property Details].[Property Ref], [Property Details].[Property Address], [Property Details].County, [Property Details].[Post Code], [Property Details].[Property Type], [Property Details].Bedrooms, [Property Details].Floor, [Property Details].[Start Date], [Property Details].[End Date], [Property Details].Rent, [Property Details].[Guaranteed Rent], [Property Details].Supplier, [Landlord Details].Firstname, [Landlord Details].Surname, [Landlord Details].[Contact Address], [Landlord Details].[Home No], [Landlord Details].[Work No], [Landlord Details].[Mobile No], [Landlord Details].[Email Address]
    FROM [Landlord Details] INNER JOIN [Property Details] ON [Landlord Details].[Landlord Ref] = [Property Details].[Landlord Ref]
    WHERE
    (
    (([Landlord Details].[Landlord Ref])=[EnterLandlordRef]) OR
    IsNull ([Landlord Details].[Landlord Ref]) OR
    [Landlord Details].[Landlord Ref]=''
    )
    AND
    (
    (([Landlord Details].Firstname)=[EnterFirstname]) OR
    IsNull ([Landlord Details].Firstname) OR
    [Landlord Details].Firstname =''
    )
    AND
    (
    (([Landlord Details].Surname)=[Enter Surname) OR
    IsNull ([Landlord Details].Surname) OR
    [Landlord Details].Surname= ''
    );

  10. #10
    Darkladymelz is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    43
    I am still having the same problem with no results showing for Landlord Ref or Firstname. Only results for Surname. This is the same when I copy and paste the SQL into a new query.

  11. #11
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Attached is small mdb in Acc2003 format. I have 2 tables and 1 query. The query accepts 3 parms. At least one parm must be filled. It does exact match. I have tested with FirstName, Surname, or Ref and seems to work. But I don't know exactly what you need.
    Hope it helps.

    Good luck.

  12. #12
    Darkladymelz is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    43
    Thank you! That is exactly what I wanted.

    I noticed that in your SQL you did not include the fuction IsNull as you included in the previous SQL above.I believe that may have been where the query was getting confused. You had replaced the AND with OR and it worked perfectly.

    WHERE ((([Landlord Details].[Landlord Ref])=[Enter Landlord Ref:])) OR ((([Landlord Details].Firstname)=[Enter Firstname:])) OR ((([Landlord Details].Surname)=[Enter Surname:]));

    Thank you for all your help.

  13. #13
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    You are welcome.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 01-10-2012, 09:56 AM
  2. Displaying Parameter Values in Page Header
    By catat in forum Reports
    Replies: 4
    Last Post: 07-16-2010, 08:47 AM
  3. Replies: 3
    Last Post: 04-04-2010, 05:26 PM
  4. Replies: 1
    Last Post: 03-27-2010, 06:13 AM
  5. Replies: 4
    Last Post: 01-05-2006, 02:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums