Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2003
    Posts
    7

    Unanswered: Change SourceObject...

    I want to change SourceObject(dynamic ??)(, in cod, after the parent form start,) for subform....it's posible??
    Thanks !

  2. #2
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Re: Change SourceObject...

    Originally posted by steaua
    I want to change SourceObject(dynamic ??)(, in cod, after the parent form start,) for subform....it's posible??
    Thanks !
    Yes its posable and there are diff ways to do it.

    This is a bit of code that I wrote to change the recordsorce of a graph.
    I use querydefs to create the recordsets and an If statment to decide wich query deff to use based on a controle group that the end user togles

    Dim Cur_DB As DAO.Database
    Dim Record_Set As DAO.QueryDef
    Dim Container_Set As DAO.QueryDef
    Dim Rev_Set As DAO.QueryDef

    Set Cur_DB = CurrentDb()

    ' delete qrydef if it exists
    For Each qdf In Cur_DB.QueryDefs
    If qdf.Name = "graph_FFE" Then
    Cur_DB.QueryDefs.Delete "graph_FFE"
    Exit For
    End If
    Next qdf
    For Each qdf In Cur_DB.QueryDefs
    If qdf.Name = "graph_Container" Then
    Cur_DB.QueryDefs.Delete "graph_Container"
    Exit For
    End If
    Next qdf
    For Each qdf In Cur_DB.QueryDefs
    If qdf.Name = "graph_rev" Then
    Cur_DB.QueryDefs.Delete "graph_rev"
    Exit For
    End If
    Next qdf

    Country_To_Country.RowSourceType = "Table/Query"

    If Measure_Selection = 1 Then
    Set Record_Set = Cur_DB.CreateQueryDef("graph_FFE", "SELECT [BTN] AS Commodity" & _
    ", Sum(Table_PCRKMS_Local_Data.FFE) AS FFE ," & _
    " (Sum(Table_PCRKMS_Local_Data.FFE)/DLookup('FFE','Table:_PCRKMS_METRICS_SUM'))*100 as [Percent]" & _
    " FROM Table_PCRKMS_Local_Data" & _
    " GROUP BY [BTN]" & _
    " ORDER BY Sum(Table_PCRKMS_Local_Data.FFE) DESC;")
    Country_To_Country.RowSource = "Select iif([Percent] > 1.5, [Commodity],'OTHER*'),sum([FFE]) from graph_FFE group by iif([Percent] > 1.5, [Commodity],'OTHER*') order by 2 desc;"
    Label_FFE.Visible = True
    Label_Containers.Visible = False
    Label_Revinue.Visible = False
    Record_Set.Close
    ElseIf Measure_Selection = 2 Then
    Set Container_Set = Cur_DB.CreateQueryDef("graph_Container", "SELECT [BTN] AS Commodity" & _
    ", Sum(Table_PCRKMS_Local_Data.Containers) AS container ," & _
    " (Sum(Table_PCRKMS_Local_Data.Containers)/DLookup('Containers','Table:_PCRKMS_METRICS_SUM')) *100 as [Percent]" & _
    " FROM Table_PCRKMS_Local_Data" & _
    " GROUP BY [BTN]" & _
    " ORDER BY Sum(Table_PCRKMS_Local_Data.Containers) DESC;")
    Country_To_Country.RowSource = "Select iif([Percent] > 1.5, [Commodity],'OTHER*'),sum([container]) from graph_Container group by iif([Percent] > 1.5, [Commodity],'OTHER*') order by 2 desc;"
    Label_FFE.Visible = False
    Label_Containers.Visible = True
    Label_Revinue.Visible = False
    Container_Set.Close
    ElseIf Measure_Selection = 3 Then
    Set Rev_Set = Cur_DB.CreateQueryDef("graph_rev", "SELECT [BTN] AS Commodity" & _
    ", Sum(Table_PCRKMS_Local_Data.Freight) AS Freight ," & _
    " (Sum(Table_PCRKMS_Local_Data.Freight)/DLookup('Freight','Table:_PCRKMS_METRICS_SUM'))*10 0 as [Percent]" & _
    " FROM Table_PCRKMS_Local_Data" & _
    " GROUP BY [BTN]" & _
    " ORDER BY Sum(Table_PCRKMS_Local_Data.Freight) DESC;")
    Country_To_Country.RowSource = "Select iif([Percent] > 1.5, [Commodity],'OTHER*'),sum([Freight]) from graph_rev group by iif([Percent] > 1.5, [Commodity],'OTHER*') order by 2 desc;"
    Label_FFE.Visible = False
    Label_Containers.Visible = False
    Label_Revinue.Visible = True
    Rev_Set.Close
    End If


    Me.Refresh
    Cur_DB.Close


    This is just one way to do it. This was the simpliest way that I have done it
    Jim

  3. #3
    Join Date
    Jan 2003
    Posts
    7

    thanks

    i study this...

  4. #4
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Re: thanks

    Originally posted by steaua
    i study this...

    heheeh I know its a bit of code let me know if i can answer any questions
    Jim

Posting Permissions

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