Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 6th, 2005, 10:07 AM
cyberpac9 cyberpac9 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 3 cyberpac9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 33 m 15 sec
Reputation Power: 0
access subform requery problem

two forms: main form has an unbound dropdown. form2 has a recordsource that is a query. sometimes we need to sort the subform....all we do is click on the Z->A button. what this does is store a value in the form2 OrderBy property field...

the problem is, when we close out the form and then open it the next time, that value is still stored in the OrderBy property field which causes a conflict with the query that form2 is bound to.

how do i make sure that when the form closes the OrderBy field is cleared out or when it is loaded for the first time the OrderBy field is cleared?

Reply With Quote
  #2  
Old July 6th, 2005, 01:41 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
Try this on the forms open event

CurrentDb.QueryDefs("NameOfQuery").SQL = "SELECT * FROM TableName"

or just use the SQL from your query without the Order By if you have selected fields from your table.

lwells

Reply With Quote
  #3  
Old July 6th, 2005, 01:52 PM
cyberpac9 cyberpac9 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 3 cyberpac9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 33 m 15 sec
Reputation Power: 0
the query used does not have a name - it is the RecordSource of the subform. so i don't have a name to put between the parentheses...that's what confuses me...in the forms properties i have the recordsource setup - the SQL statement - which works great when it is first loaded. once i sort the subform it stores a value in the OrderBy property...the record source stays the same...

Reply With Quote
  #4  
Old July 6th, 2005, 04:49 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
Gotcha,

In your main forms load event place the following code:

Dim strSQL As String
strSQL = "SELECT * FROM TableName;" 'Use correct table name here
Me!Form2.Form.RecordSource = strSQL

This would reset the recordsource back to the original format without the ORDER BY

You can also use the original SQL for the subform in place of what is above and it would do the same thing.

lwells

Reply With Quote
  #5  
Old July 7th, 2005, 10:56 AM
cyberpac9 cyberpac9 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 3 cyberpac9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 33 m 15 sec
Reputation Power: 0
great, that worked!!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > access subform requery problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT