By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

query/subform question

P: n/a
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_Click

Dim stDocName As String

stDocName = "Lookup Query"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmdShow2_Click:
Exit Sub

Err_cmdShow2_Click:
MsgBox Err.Description
Resume Exit_cmdShow2_Click

End Sub

Any help will be greatly appreciated.

Feb 27 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.RowSourceType = "Table/Query"
me.lstTest.rowsource = "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.recordsource = "select * from tablename"
end sub

or someting like that anyway

Hope that helps....
John

"Stephen D Cook" <st******@comcast.net> wrote in message
news:40********************************@4ax.com...
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_Click

Dim stDocName As String

stDocName = "Lookup Query"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmdShow2_Click:
Exit Sub

Err_cmdShow2_Click:
MsgBox Err.Description
Resume Exit_cmdShow2_Click

End Sub

Any help will be greatly appreciated.

Feb 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.