query/subform question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stephen D Cook

    #1

    query/subform question

    I have a form with txtSN text box, btnShow button, and a subform. The
    form is bound to a Table. The button is bound to a lookup query. The
    query is bound to the text box.

    I want to be able to show the query inside a box on the form using the
    button.

    When I run the form, the subform gets populated with the first record
    of the Table. I do not want this to occur. I want it to be blank or
    not visible til I click the Show button.

    When I run the form, the query pops up as a separate page, which looks
    ugly and hides some of the other items on the form. I want it to pop
    up inside the subform.

    The query does not have to be inside a subform, just a box which I can
    set the size of it.

    Here is the code I use for the Show button:

    Private Sub cmdShow2_Click( )
    On Error GoTo Err_cmdShow2_Cl ick

    Dim stDocName As String

    stDocName = "Lookup Query"
    DoCmd.OpenQuery stDocName, acNormal, acEdit


    Exit_cmdShow2_C lick:
    Exit Sub

    Err_cmdShow2_Cl ick:
    MsgBox Err.Description
    Resume Exit_cmdShow2_C lick

    End Sub

    Any help will be greatly appreciated.

  • John Sheppard

    #2
    Re: query/subform question

    Do something like this..

    Make a listbox called lstTest
    then make the onclick event of your button change the rowsource of the
    lstBox

    e.g
    Private Sub cmdShow2_Click( )
    me.lstTest.RowS ourceType = "Table/Query"
    me.lstTest.rows ource = "select * from tablename"
    end sub

    or if you wanted it to show in your subform it would be something like
    Private Sub cmdShow2_Click( )
    me.sfrTest.reco rdsource = "select * from tablename"
    end sub

    or someting like that anyway

    Hope that helps....
    John



    "Stephen D Cook" <stevedc1@comca st.net> wrote in message
    news:40m402l82v 6iqmqm4tvogav3g qlfen8320@4ax.c om...[color=blue]
    > I have a form with txtSN text box, btnShow button, and a subform. The
    > form is bound to a Table. The button is bound to a lookup query. The
    > query is bound to the text box.
    >
    > I want to be able to show the query inside a box on the form using the
    > button.
    >
    > When I run the form, the subform gets populated with the first record
    > of the Table. I do not want this to occur. I want it to be blank or
    > not visible til I click the Show button.
    >
    > When I run the form, the query pops up as a separate page, which looks
    > ugly and hides some of the other items on the form. I want it to pop
    > up inside the subform.
    >
    > The query does not have to be inside a subform, just a box which I can
    > set the size of it.
    >
    > Here is the code I use for the Show button:
    >
    > Private Sub cmdShow2_Click( )
    > On Error GoTo Err_cmdShow2_Cl ick
    >
    > Dim stDocName As String
    >
    > stDocName = "Lookup Query"
    > DoCmd.OpenQuery stDocName, acNormal, acEdit
    >
    >
    > Exit_cmdShow2_C lick:
    > Exit Sub
    >
    > Err_cmdShow2_Cl ick:
    > MsgBox Err.Description
    > Resume Exit_cmdShow2_C lick
    >
    > End Sub
    >
    > Any help will be greatly appreciated.
    >[/color]


    Comment

    Working...