A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Parameter query based subform showing all records onload



 
 
Thread Tools Display Modes
  #1  
Old November 16th, 2006, 03:08 PM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 1
Default Parameter query based subform showing all records onload

Hi,

I have a simple form with one unbound text box. It passes it's value
to a subform via a parameter query.

Forms:
frmPayroll
subfrmPayroll (based on qryPayroll)

Queries:
qryPayroll
Criteria: Like [Forms]![frmPayroll]![txtLoanNumber] & "*"

QUESTION:
Everything works fine, but when the form and subform load, it runs the
subform query, loads the subform,shows all records, and takes a fair
amount of time. What I would like is to prevent the subform from
loading or running the query until a search button is pressed.

Can anyone help?

  #2  
Old November 16th, 2006, 03:14 PM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default Parameter query based subform showing all records onload

Could you name txtLoanNumber in the LinkMasterFields, and the matching
subform control in LinkChildFields? That would bring the form up with no
records in the subform until a value is added in txtLoanNumber.

If you can't do it that way, change the criteria to a condition that always
evaluates to False, e.g.:
SELECT * FROM Table1 WHERE (False);

Then in the Click event of your search button, you can assign the desired
RecordSource, e.g.:
Dim strSql As String
If Not IsNull(Me.txtLoadNumber) Then
strSql = "SELECT * FROM Table1 WHERE LoanNumber = " &
Me.txtLoanNumber & ";"
Me.RecordSource = strSql
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

wrote in message
oups.com...

I have a simple form with one unbound text box. It passes it's value
to a subform via a parameter query.

Forms:
frmPayroll
subfrmPayroll (based on qryPayroll)

Queries:
qryPayroll
Criteria: Like [Forms]![frmPayroll]![txtLoanNumber] & "*"

QUESTION:
Everything works fine, but when the form and subform load, it runs the
subform query, loads the subform,shows all records, and takes a fair
amount of time. What I would like is to prevent the subform from
loading or running the query until a search button is pressed.

Can anyone help?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.