Welcome to SPN

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

Sign Up Now!

How to get around error...

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

Tags:
  1. James

    James
    Expand Collapse
    Guest

    I keep getting an "object variable or with block variable not set"
    error with this code....

    I want to use the loadData function twice, to get two different sets of
    data, so I figured I could use two DataSource objects and put an
    argument in the loadData Function to set which DataSource I'm using,
    but when I do it that way I keep getting that error.. Below are my
    variable declarations code and the loadData function...

    Option Compare Database

    Public Const AMPERSAND = "&"
    Public Const TAB_SPACE = " "

    'Form data source
    Dim OfferingData As DataSource
    Dim RuleData As DataSource
    Dim formData As DataSource

    Dim fm As New FormManager

    'Data source name
    Private m_sourceData As String

    'Search value
    Private m_searchValue As Variant
    -------------------------------------

    Public Function writeOfferingsXML()


    ' Declare object variables.
    Dim rs As ADODB.Recordset
    Dim rl As ADODB.Recordset
    Dim sql, outfile, dbfile As String
    Dim OfferingName, offeringUrl, OfferingCategory, OfferingSubCategory,
    OfferingGroup, _
    offeringPos, offeringRight, ToolTip, _
    offeringContext, offeringVerify, offeringCriteria As String
    Dim toolIdUrl, contextTag, HotKey As String
    Dim semicolonPos, lastPos As Integer
    Dim done As Boolean
    Dim offeringID As String


    'Return reference to current database.
    m_sourceData = "Offerings_Display"
    LoadData (OfferingData)
    Set rs = OfferingData.Dataset

    ..... some more code here, i can copy paste it if you need me to, but it
    doesn't really apply to the problem....

    End Function
    -----------------------------------------
    Private Sub LoadData(dataHolder As DataSource, Optional searchParams As
    Variant)
    Set dataHolder = Nothing
    If Not IsMissing(searchParams) Then
    If IsEmpty(searchParams) Then
    Set dataHolder = fm.GetFormData(m_sourceData, False)
    Else
    Set dataHolder = fm.GetFormData(m_sourceData, False,
    searchParams)
    End If
    Else
    dataHolder = fm.GetFormData(m_sourceData, False)
    End If
    End Sub




    it runs just fine If i get rid of the dataHolder argument and just pass
    one variable (dataHolder) through the function.... but I need it to be
    used again to get another set of data at the same time... I'm just an
    intern if you can't tell :) thanks.
     
  2. Loading...

    Similar Threads Forum Date
    Islam Beautiful Mosques around the World.... Interfaith Dialogues Aug 24, 2012
    Nature 'Supermoon' Dominates Sunday Night Skyline Around The World Breaking News May 8, 2012
    Asia's shortage of brides stirs social upheaval around region Relationships Oct 31, 2011
    Religious Tolerance Ebbing around the World, Report Finds Interfaith Dialogues Aug 10, 2011
    Northeast Tarrant Draws Religions from Around the World Interfaith Dialogues Jul 31, 2011

  3. Brendan Reynolds

    Brendan Reynolds
    Expand Collapse
    Guest

    <quote>
    Else
    dataHolder = fm.GetFormData(m_sourceData, False)
    End If
    End Sub
    <quote>

    Are you missing a 'Set' there? 'Set dataHolder = ' etc?

    --
    Brendan Reynolds
    Access MVP

    "James" <jamesburkett@gmail.com> wrote in message
    news:1150897838.051523.108560@i40g2000cwc.googlegroups.com...
    >I keep getting an "object variable or with block variable not set"
    > error with this code....
    >
    > I want to use the loadData function twice, to get two different sets of
    > data, so I figured I could use two DataSource objects and put an
    > argument in the loadData Function to set which DataSource I'm using,
    > but when I do it that way I keep getting that error.. Below are my
    > variable declarations code and the loadData function...
    >
    > Option Compare Database
    >
    > Public Const AMPERSAND = "&amp;"
    > Public Const TAB_SPACE = " "
    >
    > 'Form data source
    > Dim OfferingData As DataSource
    > Dim RuleData As DataSource
    > Dim formData As DataSource
    >
    > Dim fm As New FormManager
    >
    > 'Data source name
    > Private m_sourceData As String
    >
    > 'Search value
    > Private m_searchValue As Variant
    > -------------------------------------
    >
    > Public Function writeOfferingsXML()
    >
    >
    > ' Declare object variables.
    > Dim rs As ADODB.Recordset
    > Dim rl As ADODB.Recordset
    > Dim sql, outfile, dbfile As String
    > Dim OfferingName, offeringUrl, OfferingCategory, OfferingSubCategory,
    > OfferingGroup, _
    > offeringPos, offeringRight, ToolTip, _
    > offeringContext, offeringVerify, offeringCriteria As String
    > Dim toolIdUrl, contextTag, HotKey As String
    > Dim semicolonPos, lastPos As Integer
    > Dim done As Boolean
    > Dim offeringID As String
    >
    >
    > 'Return reference to current database.
    > m_sourceData = "Offerings_Display"
    > LoadData (OfferingData)
    > Set rs = OfferingData.Dataset
    >
    > .... some more code here, i can copy paste it if you need me to, but it
    > doesn't really apply to the problem....
    >
    > End Function
    > -----------------------------------------
    > Private Sub LoadData(dataHolder As DataSource, Optional searchParams As
    > Variant)
    > Set dataHolder = Nothing
    > If Not IsMissing(searchParams) Then
    > If IsEmpty(searchParams) Then
    > Set dataHolder = fm.GetFormData(m_sourceData, False)
    > Else
    > Set dataHolder = fm.GetFormData(m_sourceData, False,
    > searchParams)
    > End If
    > Else
    > dataHolder = fm.GetFormData(m_sourceData, False)
    > End If
    > End Sub
    >
    >
    >
    >
    > it runs just fine If i get rid of the dataHolder argument and just pass
    > one variable (dataHolder) through the function.... but I need it to be
    > used again to get another set of data at the same time... I'm just an
    > intern if you can't tell :) thanks.
    >
     

Share This Page