Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

dumb question, but i've forgotten

Discussion in 'Information Technology' started by James, Jul 28, 2006.

  1. James

    James
    Expand Collapse
    Guest

    I've got a Class Module "DBAdmin" and a form "Administration". I have a
    public string variable in the dbadmin and i want to use it in
    administration msgbox.

    'This is the Administration form
    Private Sub cmdImportOfferings_Click()
    Dim dbUtils As New DBAdmin

    If dbUtils.ImportXML("C:\Offerings Project\offerings.xml") Then
    MsgBox "Offerings XML successfully imported"
    Else
    'it doesn't lke the next line
    MsgBox DBAdmin.ErrorMsg
    End If

    Set dbUtils = Nothing
    End Sub


    -----------------------------
    'this is the DBAdmin Class Module


    Dim ErrorMsg As String
    Public Function ImportXML(FileName As String) As Boolean
    On Error GoTo Error_Handler

    'Dim appAccess As New Access.Application

    'appAccess.ImportXML DataSource:=fileName,
    ImportOptions:=acStructureAndData
    Application.ImportXML FileName, acStructureAndData

    ImportXML = True
    Exit_Method:
    Set appAccess = Nothing
    Exit Function

    Error_Handler:
    ImportXML = False
    ErrorMsg = Err.Description
    GoTo Exit_Method
    End Function



    Thanks.
     
  2. Loading...

    Similar Threads Forum Date
    Islam Dumbest Reasons for Converting to Islam Interfaith Dialogues Apr 21, 2011
    Sikh News Obama: "Punjab" Memo Was A "Dumb Mistake" (CBS News) Breaking News Jun 19, 2007
    General How dumb can you get....batch ke kurio! Hard Talk Mar 10, 2007
    Question About GGS Questions and Answers Aug 28, 2016
    Marriage And Discrimination Related Questions Blogs Mar 21, 2016

  3. Graham R Seach

    Graham R Seach
    Expand Collapse
    Guest

    James,

    Add a property to the class:
    Public Property Get ErrMsg() As String
    ErrMsg = ErrorMsg
    End Property

    But I think you'd be better server by percolating the error back to the
    calling procedure. You can do that in the class using either CVErr(), a
    public event, or by using Err.Raise. Using the public event scenario would
    required declaring the class object variable using WithEvents, and trapping
    the event in the form. Using the Err.Raise method requires you to use 'On
    Error Goto 0' in the class, and trapping the error in the form. The code I
    supplied, however, is the simplest option.

    Regards,
    Graham R Seach
    Microsoft Access MVP
    Sydney, Australia
    ---------------------------

    "James" <jamesburkett@gmail.com> wrote in message
    news:1152796486.904711.241110@s13g2000cwa.googlegroups.com...
    > I've got a Class Module "DBAdmin" and a form "Administration". I have a
    > public string variable in the dbadmin and i want to use it in
    > administration msgbox.
    >
    > 'This is the Administration form
    > Private Sub cmdImportOfferings_Click()
    > Dim dbUtils As New DBAdmin
    >
    > If dbUtils.ImportXML("C:\Offerings Project\offerings.xml") Then
    > MsgBox "Offerings XML successfully imported"
    > Else
    > 'it doesn't lke the next line
    > MsgBox DBAdmin.ErrorMsg
    > End If
    >
    > Set dbUtils = Nothing
    > End Sub
    >
    >
    > -----------------------------
    > 'this is the DBAdmin Class Module
    >
    >
    > Dim ErrorMsg As String
    > Public Function ImportXML(FileName As String) As Boolean
    > On Error GoTo Error_Handler
    >
    > 'Dim appAccess As New Access.Application
    >
    > 'appAccess.ImportXML DataSource:=fileName,
    > ImportOptions:=acStructureAndData
    > Application.ImportXML FileName, acStructureAndData
    >
    > ImportXML = True
    > Exit_Method:
    > Set appAccess = Nothing
    > Exit Function
    >
    > Error_Handler:
    > ImportXML = False
    > ErrorMsg = Err.Description
    > GoTo Exit_Method
    > End Function
    >
    >
    >
    > Thanks.
    >
     

Share This Page