Results 1 to 3 of 3
  1. #1
    sephiroth2906 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    73

    Cause query to ask for name at startup


    Hello all!

    I have a form that reports to a table specific information about employees. When I want to view the information, I am only going to be interested in viewing a single employees entries over the course of the last year.

    I used the criteria "Like [" to ask for a name at startup, but I was wondering if there was a way to make that selectable from a combo box or some other way to avoid having to type the entire name exactly.

    The second part is a bit tougher. Instead of putting in a date range here, what I would like the query to do is automatically look at the last year ending on whatever today's date is. I could create a between criteria, but I assume that this is possible.

    I really appreciate the help!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    This will give this date a year ago
    dateserial(Year(date)-1,Month(date),Day(date))
    If you could identify an employee by some characters in the lastname. For example, you could try something like this

    PARAMETERS [What Lastname] string;
    SELECT YourTable.*
    FROM YourTable
    WHERE (Table.Lastname Like [What Lastname] & "*") AND
    YourDate Between dateserial(Year(date)-1,Month(date),Day(date)) and Date;

    This would search for a Lastname such as Johnson using John but would also find Johnnson or Johnsville
    You would have to type in enough characters for a unique lookup (from the left)


    And to answer your question, yes you could use a form and a combobox.
    You could also tailor the query to select specific fields.

  3. #3
    sephiroth2906 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2011
    Posts
    73
    Thanks for the advice orange!

    Unfortunately, I have not progressed far enough in my Access studies to utilize those suggestions. That is my fault and not yours.

    I did, however, find something I can wrap my head around, and thought I would put it in here in case someone else finds it useful.

    For the date, I can put this in the criteria:

    >=DateAdd("m",-12,Date())

    Which will give me only the last twelve months.

    As for the name, I did figure out I could put a wild card in, and as long as I typed enough to match one name, I was golden.

    Example, john* would find Johnson, Michael

    So I can still use the criteria

    Like [Lastname, Firstname]

    I hope to someday move beyond this, but it will do for now.

    Thanks again!

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

Similar Threads

  1. startup view
    By Canaglia in forum Database Design
    Replies: 5
    Last Post: 11-03-2011, 10:23 AM
  2. Help with startup
    By Tari in forum Programming
    Replies: 5
    Last Post: 03-07-2011, 05:07 PM
  3. Switchboard at startup
    By jamie c in forum Access
    Replies: 10
    Last Post: 03-04-2010, 12:16 PM
  4. Tools>Startup... MISSING
    By bbylls in forum Access
    Replies: 4
    Last Post: 12-21-2009, 09:02 AM
  5. startup problem
    By Eric1066 in forum Access
    Replies: 3
    Last Post: 12-07-2009, 10:01 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