Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Call Procedure (Access 2002)

    Hi

    Second question of the day.

    In the form an user clicks on a button to export data to a file (there are several of these buttons exporting different data). On clicking the button, it calls two procedures as follows:

    Private Sub ComConsumpData_Click()
    Call Checking
    Call ExportRename(1, Me!txtPath, Me!TxtFileName)

    Exit_ComConsumpData:
    Exit Sub
    End Sub

    The first procedure checks to see if the file name the user has selected in the form is a) exists and [img]/forums/images/smilies/cool.gif[/img] does not include non alphacharacters. If all ok, then the 2nd procedure is called. This code is the same for all the export buttons. My question is what is the simplest way to terminate the command if checking procedure finds a problem (it gives an error message to the user) ie do not call the 2nd procedure Call ExportRename(1, Me!txtPath, Me!TxtFileName).

    Thanks and Regards

    WTH

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Call Procedure (Access 2002)

    Make Checking into a function that returns a Boolean (True/False) value, for instance True if all checks are OK, False if there is a problem.

    Public Function Checking() As Boolean
    ...
    If ... Then
    ' Failed a test
    Checking = False
    Exit Function
    End If
    ...
    ' Passed all tests
    Checking = True
    End Function

    Private Sub ComConsumpData_Click()
    If Checking = True Then
    ExportRename 1, Me!txtPath, Me!txtFileName
    End If
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Call Procedure (Access 2002)

    Hi Hans

    Thanks again. I was thinking passing a variable, but the method you suggested is more efficient.

    Regards
    WTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •