Results 1 to 3 of 3

Thread: Access VBA HELP

  1. #1
    Join Date
    May 2013
    Posts
    1

    Red face Unanswered: Access VBA HELP

    High everyone i am working on some VBA inside access and am really stuck i get a compile error that says line not defined. this is the code and the error is defined at the line On Error GoTo ImportParticipants_Err


    '------------------------------------------------------------
    ' mcrImportParticipants1
    '
    '------------------------------------------------------------
    Function mcrImportParticipants()
    'This procedure imports new participants into the Putts database
    'This procedure was written by Matt Pream
    On Error GoTo ImportParticipants_Err


    Dim ParticipantDialog As Object
    Set ParticipantDialog = Application.FileDialog(msoFileDialogOpen)

    With ParticipantDialog
    .Title = "Select New Participant Lits(s)"
    .AllowMultiSelect = True


    If .Show = True Then
    Dim ImportFileName As Variant
    For Each ImportFileName In .SelectedItems
    DoCmd.TransferSpreadsheet acImport, 10, _
    "tblParticipant", ImportFileName, True, ""
    Next
    Else
    MsgBox "You Cancelled the import"
    End If
    End With

    ImportParticipants_Exit:
    Exit Function

    ImportParticipant_Err:
    MsgBox Error$

    End Function

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Your OnError statement is

    On Error GoTo ImportParticipants_Err

    but the Function's name is actually

    mcrImportParticipants

    and your OnError an Exit lines needs to reflect this actual name.

    You need to always heed my signature:

    The Devil's in the Details!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Nov 2008
    Posts
    24
    Try changing to the following the error sub to:
    ImportParticipants_Err: 'note the "s" is added
    MsgBox ("Error: " & Err.number & VBCRLF & Err.description)
    goto ImportParticipants_Exit

Posting Permissions

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