[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bump::msaccess

Title:MSACCESS
Moderator:BUMP::HONER
Created:Tue Dec 01 1992
Last Modified:Mon Jun 02 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1661
Total number of notes:6339

1642.0. "no records found" by TIEFLY::VARDARO () Tue Mar 18 1997 10:29

    Hi,
    
    I'd like to find out how to go about handling this situation.
    
    I have two screens for the same table, one for entering, one
    for modifying (not the best design, I know ..).  For the
    modify screen, I have a macro that tells it to bring up the 
    first record and and to go to a specific field on the form.
    
    That all works fine, if there is a record to find.  If not,
    I get a macro error screen and have to halt.
    
    How do I  get around this 'null' table problem?  I would like
    to bring up a message box indicating that no records were
    found, I'm just not sure where or how to do that ..
    
    Thanks for any help you can send my way ..
    
    Nancy
T.RTitleUserPersonal
Name
DateLines
1642.1DCOUNT FUNCTIONPOLAR::GOSLINGKAO - 621-4519Tue Mar 18 1997 14:5129
        Re:          <<< Note 1642.0 by TIEFLY::VARDARO >>>

Nancy,

Under Access Basic (V2), use the Dcount function to check for records. If
there are none found then display the message box and exit the
subroutine. If there are records found, then continue with the process.

Code looks something like:

        IsRecords = Dcount("*","table_name")
        If IsRecords = 0 then 
                msgbox "There are no records"
                exit sub
        else
                ....do whatever it is you are wanting to peform
        end if
        
If you are using a macro then I think - but I'm not 100% sure as I don't
use macros all that much - you use it something like:

        Condition                       Action
        Dcount("*","table_name") = 0    Msgbox
        ...                             CancelEvent
        
Hope this helps or at least gets you thinking in the right direction.

Art

1642.2thanksTIEFLY::VARDAROWed Mar 19 1997 09:483
    Thank you!  That definitely gives me a direction I can go in.
    
    Nancy