Results 1 to 8 of 8
  1. #1
    HotelierDream is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    31

    Check if Values exists in Table if true then stop code... (How?)

    Hello All,



    Over the past week I have learned alot about access, VBA, BAT, SQL and many other things. I have made my first WORKING (Big deal for me after spending hours coding and 8 different prototypes) DB to help with generating night audit reports for a hotel. Now I need a little help to do the following:

    If text9 = Any Value in Tables!Log!AuditDate then stop VBA code and display msg box, if not then run code.

    I want to either A. Easily tie into command buttons or B. Turn into a module that makes it easy to input at the top of a function.

    Any ideas? I have searched all over google and cant find Access VBA examples.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    When you do the test (If statement) if it returns True, show message then next line, Exit Sub
    If you're asking for help with the test, then it's not clear what that test is (at least to me).

    In actual fact, you cannot stop code then show a message box. The latter precludes the former.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    HotelierDream is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    31
    Quote Originally Posted by Micron View Post
    When you do the test (If statement) if it returns True, show message then next line, Exit Sub
    If you're asking for help with the test, then it's not clear what that test is (at least to me).

    In actual fact, you cannot stop code then show a message box. The latter precludes the former.

    How would I word the If statement so that it looks up values in a specific field on a table? What you said makes sense I just am not sure how to code the If statement.

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,399
    question asked and answered here as part of the overall dialogue

    https://www.access-programmers.co.uk...import.315442/

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Ajax, if that is relevant I missed it. Seems to be about a) data connections and then b) moving files.

    My answer to the last question would be to use the DLookup function though - if it is only one value that is being looked up at any one time

    If DLookup (parameters here) = something Then
    Msgbox ...
    Exit Sub
    End If
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,399
    see post #27

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Yeah, I read through it all. Not sure how the DCount function relates to the request
    How would I word the If statement so that it looks up values in a specific field on a table?
    I must be mistaken as to what's being asked for here as I'm not interpreting that statement as wanting a count of anything.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,399
    my interpretation of

    If text9 = Any Value in Tables!Log!AuditDate then stop VBA code and display msg box, if not then run code.

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

Similar Threads

  1. Function To Check If Table Exists
    By chalupabatman in forum Programming
    Replies: 6
    Last Post: 11-16-2017, 01:23 PM
  2. Replies: 1
    Last Post: 08-09-2015, 10:03 AM
  3. VBA code to check if a record already exists
    By fra90 in forum Programming
    Replies: 3
    Last Post: 11-20-2013, 11:20 AM
  4. How to check if Table already exists
    By riaarora in forum Access
    Replies: 1
    Last Post: 08-12-2012, 09:48 AM
  5. Check to see if record id exists in joined table
    By csoseman in forum Programming
    Replies: 1
    Last Post: 08-18-2011, 01:06 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