Results 1 to 6 of 6
  1. #1
    jpiazza is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Posts
    3

    If then statement using Yes/No criteria

    Background - When a button is clicked - I want it to goto 1 of 2 forms based on whether a person is a manager or not. I have a field 'Approver' in the Employees table that is a check box (yes or no).

    however when I click on the button it gives me an error that says - "The object doesn't contain the automation object 'Employees' "

    its having an issue with this line that's underlined: - what is wrong with this?

    If [Employees]![Approver]=True Then
    Open form for Managers
    Else
    Open form for Non-managers


    End

    Thanks for any assistance !

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    If the form that holds this button is bound to the Employees table, try:
    If Me.[Approver]=True Then
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    jpiazza is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Posts
    3
    the form isn't bound to the table. When I put in Me.[Approver]=True - it changes the Me to [Me].[Approver]=True and get the same message.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    In that case, perhaps you could use DLookup() to return the value of the "Approver" field. See: http://www.techonthenet.com/access/f...in/dlookup.php
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    jpiazza is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2014
    Posts
    3
    Thank you - that worked. However I'm not sure if this is giving what I'm looking for. I'm trying to evaluate whether or not the field [Approver] is checked or not.

    The If Then statement now says

    If DLookUp("[Approver]","Employees","approver=yes") Then

    Approver is a check box - yes/no - yes the person is an approver/Manager.
    When the criteria ie: approver box is not checked, it should goto the ELSE side of the If..Then statement, but doesn't.

    How do you indicate this ?

    Thanks again.

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    No. I'm sure this is not what you need. The criteria argument of the function should should be used to find the only record from which you want the Approver value returned. I assume your Employees table has a Primary Key field, lets say it's called EmpID. The criteria would then be "[EmpID] = " & Me.textBox if EmpID is numeric. In this example "Me.txtBox" would be a control on the form which has the EmpID value of the person you want to evaluate.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Help with two criteria in an IIF statement.
    By Orozvik in forum Queries
    Replies: 1
    Last Post: 04-26-2013, 02:58 PM
  2. Need Criteria added SQL Statement
    By Ran in forum SQL Server
    Replies: 4
    Last Post: 07-31-2012, 10:07 AM
  3. using two criteria in one case statement
    By chessico in forum Access
    Replies: 5
    Last Post: 03-14-2012, 03:25 PM
  4. Iif statement with multiple criteria
    By coach32 in forum Queries
    Replies: 1
    Last Post: 09-07-2011, 01:28 AM
  5. nested if statement with two criteria
    By kendra in forum Queries
    Replies: 5
    Last Post: 06-16-2009, 04:07 PM

Tags for this Thread

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