Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Location
    Charlotte, NC
    Posts
    45

    Post Unanswered: Needed: Guru on RecordSource

    I need the record source of a subform "set to the table a combo box points to".

    I've been told it must be possible. Possibly simular to the following code:


    me!theSubFormName.form.recordsource = sqlString

    where sqlString would be
    SELECT * FROM ???????

    I'm lost because my source will change as a new source is selected from a combo box..

    Any one have any advice?

    -------

    Thanks to izyrider for all the help so far!
    -----

    "How much deeper would the ocean be without sponges?"

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

    Re: Needed: Guru on RecordSource

    Originally posted by stratego16
    I need the record source of a subform "set to the table a combo box points to".

    I've been told it must be possible. Possibly simular to the following code:


    me!theSubFormName.form.recordsource = sqlString

    where sqlString would be
    SELECT * FROM ???????

    I'm lost because my source will change as a new source is selected from a combo box..

    Any one have any advice?

    -------

    Thanks to izyrider for all the help so far!

    I have neaver set a subform rowsource....but i have set other object rowsource. This is an examble of a combo box


    Dim Cur_DB As DAO.Database
    Dim Record_Set As DAO.QueryDef
    Set Cur_DB = CurrentDb()

    ' delete qrydef if it exists
    For Each qdf In Cur_DB.QueryDefs
    If qdf.Name = "Combo" Then
    Cur_DB.QueryDefs.Delete "Combo"
    Exit For
    End If
    Next qdf
    Set Record_Set = Cur_DB.CreateQueryDef("Combo", "SELECT [REF_GLOBAL_COMBO_LU_TBL].[EQU_TYPE]" & _
    " FROM REF_GLOBAL_COMBO_LU_TBL" & _
    " where week between " & From_week & to_week & _
    " and [REF_GLOBAL_COMBO_LU_TBL].[EQU_TYPE] <> '' " & String_Var & Service_Contract & _
    Reef_Dry & BTN & _
    Account & RCountry & POR & Load & Discharge & Pod & DCountry & Nvocc & Direction & _
    " Group By [REF_GLOBAL_COMBO_LU_TBL].[EQU_TYPE]" & _
    " Order by [REF_GLOBAL_COMBO_LU_TBL].[EQU_TYPE]")

    Record_Set.Connect = "ODBC;Description=DataWarehouse;DRIVER=SQL Server;SERVER=scnc044db;UID=globalsales;PWD=global ;Network=DBMSSOCN;"
    equ_combo.rowsourcetype = "table/query"
    Equ_Combo.RowSource = "Select EQU_TYPE from Combo order by EQU_TYPE"


    basicaly i create a querydef using lots of vairables to test the data selections that my end user has made (totaly usless to you) then I use the query def in the .rowsouerce comand.
    the .connection information is only usfull for sql pass threw querys, you will not need that line.
    let me know if this is too confusing maybe i can help a bit
    Jim

  3. #3
    Join Date
    Apr 2002
    Posts
    139
    Suppose your combo-box is on the frmMainForm
    And that the name of the control that holds your subform is ctrSubForm
    And that the name of the combo-box on the Mainform is cboMyChoice

    Than use the after-update event of your combo-box for:

    Forms("frmMainForm").ctrSubForm.Form.RecordSource = "SELECT YourTable.* WHERE (((YourTable.FieldToSelectOn)='" & cboMyChoice & "')) ;"

    Me.Requery

    hth

Posting Permissions

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