Results 1 to 9 of 9
  1. #1
    wilbr73 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    10

    If greater than 0 then...

    I want to have a query that looks for orphaned records when importing data from an excel spreadsheet. I have everything working from the import to the count orphaned records, to count the number of records, a message box that pops up and alerts the user of orphaned records... I am able get everything to work as long as I put in the exact number of records that are orphaned. What is the correct way to say "greater than 0" so access will open up the message box for any number of orphaned records?

    Thanks,
    Will

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Where are you putting in the 'exact number of records'?

    Criteria under the appropriate field: >0

    Show the query SQL statement and code for analysis if you need more help.
    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.

  3. #3
    wilbr73 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    10
    Here is how I have it set up...

    I have an unmatched query that tells me when I have orphaned records, I have a form built on that query to display the records and on that form is an unbound box that I have set up with the count function to display the number of records. I have an If then macro built that looks at the calculated field. If there is a value I want it to display the message box alerting the user of the orphaned records. If there are none than I want the macro to just close the form/query. When I put in fake records so that I know exactly how many orphaned records I have and I put in that value in the if then statement, the macro runs just fine. If I put in >0 then it skips and goes straight to closing the form/query.

    Here is a screen shot of what I have... If I put in 5 orphaned records, for example, and I type in =5 into the highlighted area then the macro runs just fine. If I put in >0 as it is right now, the macro just skips over the message box and closes the window.

    The screen shot is below.

  4. #4
    wilbr73 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    10

  5. #5
    wilbr73 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    10
    So the screen shot won't work so here is attempt #2. Here is how the macro looks in the macro builder.

    if [Forms]![frmUnpairedPlateLayoutSamples]![Text56]>0
    Message box
    Message: There are samples on the layout that are not associated with a sample in the database.
    Beep: yes
    Type: none
    Title: Samples Not Present
    Else
    CloseWindow
    Object Type: Form
    Object Name:frmUnpairedPlateLayoutSamples
    Prompt: Yes

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Looks good to me. If =5 works then >0 should, so should >=1. But I don't use macros, only VBA.
    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.

  7. #7
    wilbr73 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    10
    I will try the >=1 trick and see if that works.

    Do you have any suggestions for references to get started in VBA? I know that is where the action is for really taking the database to the next level. I am a complete beginner when it comes to VBA.

    Thanks.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I never got any books on Access and VBA (I had a mentor to guide me) but I am sure many good ones available. I did get some old books on Visual Basic which is very similar to VBA. This book looks interesting: Access™ 2007 Programming by Example with VBA, XML, and ASP by Julitta Korol, Wordware Publishing, Inc.

    Lots of tutorials on web, just Google it. This one looks promising http://www.access-vba.net/introducti...ccess-vba.html
    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.

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Here's a site I usually recommend as a great starting point, having 28 well written, well defined, clearly named chapters.

    http://www.functionx.com/vbaccess/index.htm

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Times greater than 24 hours
    By ccordner in forum Access
    Replies: 2
    Last Post: 11-28-2011, 12:46 PM
  2. Replies: 5
    Last Post: 06-13-2011, 01:30 PM
  3. Greater than or equal to date
    By stryder09 in forum Access
    Replies: 1
    Last Post: 04-14-2011, 03:54 PM
  4. Joins to get records greater than
    By thart21 in forum Queries
    Replies: 10
    Last Post: 09-15-2010, 08:45 AM
  5. Greater than date
    By I-am-me in forum Queries
    Replies: 1
    Last Post: 08-18-2009, 05:21 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