Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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
    Anyone Have Any Unanswered Questions On Sikhi Or God? Sikh Sikhi Sikhism Jan 7, 2017
    Question About Translations Questions and Answers Dec 20, 2016

  3. OP
    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.
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page