Results 1 to 4 of 4
  1. #1
    kfc is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    3

    Post how to implementing substitution variables in access 2007

    is there a way i can use substitution variables in access 2007, i wrote a query that returns rows which have a word okeu in them but i want to use substitution variables so that i can retrieve any word i want and if the word i want is not there i want to pop a message saying word not there its easier to do it in oracle sqlplus but how can i apply it in access using sql queries??any ideas,thanks in advance

    this is my sql i made in access


    Code:
    SELECT MENU.NAME_REC, MENU.C_REC, AUTO.C_GROUP
    FROM MENU, AUTO
    WHERE (((MENU.NAME_REC)="okeu"));
    .

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Take a look at Parameter Queries. When you run the query, it will prompt you for what you want to look for at run-time.

    Code:
    SELECT MENU.NAME_REC, MENU.C_REC, AUTO.C_GROUP
    FROM MENU, AUTO
    WHERE (((MENU.NAME_REC)=[What value do you want to search for?]));
    The only thing is if it does not find anything, it will return an empty set, not any sort of message. If you want something like that, it will probably require VBA.

    By the way, shouldn't you have a relationship (join) between your MENU and AUTO fields? Otherwise, your query (as written) will return the Cartesian Product of the two objects.

  3. #3
    kfc is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    3
    thanks i noticed it does not return any message was hoping it does like some kind of validation but anyway thanks for the answer

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    thanks i noticed it does not return any message was hoping it does like some kind of validation but anyway thanks for the answer
    Queries themselves can only return data from the objects included in the data. As I said, if you want some sort of message to display, you will need to use VBA. You can create the SQL code of your query in VBA, then check to see how many records it will return, and if it is zero, you can return a message box, otherwise you can choose to return the results of the query.

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

Similar Threads

  1. Implementing Office add-in for Access 2010 Runtime
    By tachyon in forum Programming
    Replies: 0
    Last Post: 03-25-2012, 11:20 PM
  2. Variable substitution problem.
    By bsc in forum Programming
    Replies: 2
    Last Post: 01-11-2012, 09:33 AM
  3. Replies: 2
    Last Post: 06-18-2011, 09:55 AM
  4. Implementing a Delete Query
    By mwabbe in forum Queries
    Replies: 5
    Last Post: 09-20-2010, 12:09 PM
  5. Implementing Math Formula
    By cwwaicw311 in forum Forms
    Replies: 19
    Last Post: 02-24-2010, 08:10 AM

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