Results 1 to 2 of 2
  1. #1
    guillermoftw is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2014
    Posts
    13

    Running SQL using IF ELSE statement

    Hi everyone,



    I utterly new to VBA and the goal of my code is to have an IF ELSE statement look into a table in my access DB, find a particular value and then run a SQL query based off of that value. The column can have two different values which is either associated or related. So my logic looks like this:


    public function abcd()
    IF "column value = related"
    DoCmd.RunSQL = "sql statement 1"
    ELSE "column value = associated"
    DoCmd.RunsSQL = "sql statement 2"

    Any help would be much appreciated.

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    A DLookup domain aggregate function can do a quick search of table. Access Help has guidelines on Domain Aggregate functions.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Running a Query using "Like" statement
    By dsegu in forum Queries
    Replies: 3
    Last Post: 08-05-2014, 11:26 AM
  2. Replies: 7
    Last Post: 04-01-2014, 03:38 PM
  3. Running queries, VIA VB, but not running in Order
    By mike02 in forum Programming
    Replies: 6
    Last Post: 06-01-2013, 07:07 AM
  4. Replies: 5
    Last Post: 03-03-2013, 07:18 AM
  5. Running a Select statement in VBA
    By geraldk in forum Forms
    Replies: 12
    Last Post: 05-04-2012, 01:23 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