Results 1 to 3 of 3
  1. #1
    choymns is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2012
    Posts
    1

    how can i write IIF statement when i use radio button

    I created a form Contains a text box to search in name field
    and two radio buttons , One to search at the beginning of the Name field and the other to search at any part of the field
    I also created a button to open the search query and I wrote IIF statement as
    IIf([Forms]![form name]![radio button name].[OptionValue]= -1 ;([table name].[name field]) Like "*" & [Forms]![form name]![text box name] & "*";([table name].[name field]) Like [Forms]![form name]![text box name] & "*")


    but it not work correctly , Where error in IIF statement
    and what The best way to create this form
    I am new to access. Please help


  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    The syntax for the iif function is:

    iif(test, truepart, falsepart), i.e. commas, not semicolons.
    I didn't look for other errors which may be present.
    Quote Originally Posted by choymns View Post
    I created a form Contains a text box to search in name field
    and two radio buttons , One to search at the beginning of the Name field and the other to search at any part of the field
    I also created a button to open the search query and I wrote IIF statement as
    IIf([Forms]![form name]![radio button name].[OptionValue]= -1 ;([table name].[name field]) Like "*" & [Forms]![form name]![text box name] & "*";([table name].[name field]) Like [Forms]![form name]![text box name] & "*")
    but it not work correctly , Where error in IIF statement
    and what The best way to create this form
    I am new to access. Please help


  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by choymns View Post
    I created a form Contains a text box to search in name field
    and two radio buttons , One to search at the beginning of the Name field and the other to search at any part of the field
    I also created a button to open the search query and I wrote IIF statement as
    IIf([Forms]![form name]![radio button name].[OptionValue]= -1 ;([table name].[name field]) Like "*" & [Forms]![form name]![text box name] & "*";([table name].[name field]) Like [Forms]![form name]![text box name] & "*")
    but it not work correctly , Where error in IIF statement
    and what The best way to create this form
    I am new to access. Please help
    It would help to see the complete procedure for the button, but this is what I see.

    You can't refer to the field using [table name].[name field] syntax.
    If the option buttons are part of a frame, you need to refer to the frame value. It will be an integer, usually 1,2,3,...
    If it is not part of a frame, you would use IIf([Forms]![form name]![radio button name] = TRUE, .........

    If you are trying to limit the recordset for a form that is already open, you should set a filter. If you are going to open a form and filter the recordset, use the WHERE clause of the open form command.

    (And the aforementioned semicolon instead of a comma in the If() function.)

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

Similar Threads

  1. Option/Radio Button Problem
    By benthamq in forum Forms
    Replies: 6
    Last Post: 09-16-2011, 09:48 AM
  2. Combo Box Determines Radio Button Selected
    By sainttomn in forum Forms
    Replies: 5
    Last Post: 08-10-2011, 03:51 PM
  3. radio button and checkbox
    By Fifa in forum Access
    Replies: 2
    Last Post: 01-19-2011, 10:20 AM
  4. Radio Button Select in WebBrowser
    By access_man in forum Access
    Replies: 3
    Last Post: 10-27-2010, 05:29 PM
  5. Select Radio Button and another one turns off
    By Lockrin in forum Programming
    Replies: 1
    Last Post: 02-09-2010, 02:17 PM

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