473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Query subform using a value from table

Hi this is what i have so far, but it doesnt seem to be working right. I am getting an error here: qryReferral.Status = 'Open'
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFltrOpen_Click()
  2.  
  3.     Dim sSQL As String
  4.  
  5.     sSQL = "SELECT * FROM qryReferral WHERE qryReferral.Completed = False AND qryReferral.Status = 'Open' ORDER BY qryReferral.ReferralDate;"
  6.     Me![frmReferralSub].Form.RecordSource = sSQL
  7.  
  8. End Sub
Thanks
Sep 14 '09 #1

✓ answered by ChipR

I don't really see anything wrong on the surface.
What's the query look like for the subform when it does show records, before you click a command button?
What happens if you try actually filtering instead?
Expand|Select|Wrap|Line Numbers
  1. frmReferralSub.Form.Filter = "[Status] = 'Open'" 
  2. frmReferralSub.Form.FilterOn = True 
If that doesn't work, what are the field types you're working with?

13 1903
ChipR
1,287 Expert 1GB
What error?
Sep 14 '09 #2
ajalwaysus
266 Expert 100+
First, please put your code in the [code] brackets:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFltrOpen_Click()
  2. Dim sSQL As String
  3.  
  4. sSQL = "SELECT * FROM qryReferral WHERE qryReferral.Completed = False AND qryReferral.Status = 'Open' ORDER BY qryReferral.ReferralDate;"
  5. Me![frmReferralSub].Form.RecordSource = sSQL
  6.  
  7. End Sub
  8.  
Second, please post the error text you are getting.

-AJ
Sep 14 '09 #3
Hi, sorry about that. I am not getting an error message, but i i test using the command button, the subform goes to new record and does not show the results.
Sep 14 '09 #4
ajalwaysus
266 Expert 100+
As far as I can tell, I see nothing wrong with your query. This may be a problem with the logic, since the syntax seems fine to me. You will need to review that, if it is still an issue you will need to give us enough information to be on the same page as you so we can debug with you.

ChipR, your opinion.

-AJ
Sep 14 '09 #5
Ok thanks. i have a form called frmReferral, which has a subform frmReferralSub displaying records based on a query qryReferral. i have a command buttons to query the different records by status. one buttton for OPEN, one for CLOSED, etc. When the OPEN button is clicked i would like the subform to be "filtered" so that only records that which have a status of OPEN in the qryReferral.Status field.
Sep 14 '09 #6
ajalwaysus
266 Expert 100+
If you copy this data to a query and run it, does it work?

-AJ
Sep 14 '09 #7
Hi,yes it does.

LL
Sep 14 '09 #8
ChipR
1,287 Expert 1GB
I don't really see anything wrong on the surface.
What's the query look like for the subform when it does show records, before you click a command button?
What happens if you try actually filtering instead?
Expand|Select|Wrap|Line Numbers
  1. frmReferralSub.Form.Filter = "[Status] = 'Open'" 
  2. frmReferralSub.Form.FilterOn = True 
If that doesn't work, what are the field types you're working with?
Sep 14 '09 #9
the filter worked, are there any drawbacks to using the filter instead of "Me![frmReferralSub].Form.RecordSource" ?
Sep 14 '09 #10
ChipR
1,287 Expert 1GB
From a performance perspective, I think you're at least as well off filtering the one field rather than resetting the RecordSource. I haven't tested it though.
Sep 14 '09 #11
thank you so much, you have been very helpfull, i really appreciate it.

LL
Sep 14 '09 #12
ajalwaysus
266 Expert 100+
I'd like someone to confirm this, but I thought I heard that using the filter function doesn't use indexes when filtering the data, but using a query does. I could be wrong, I will look into it if someone doesn't have a quick answer.

-AJ
Sep 14 '09 #13
NeoPa
32,556 Expert Mod 16PB
That would be useful AJ. I've never heard that before. Worrying if true.

On the point of filtering, I always advise creating a general purpose query then filtering the form as a separate thing. Usually in the Open call, but can also be done perfectly well on the fly when the form is already open.
Sep 14 '09 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John | last post by:
Hi - I am trying to perform a simple append query, with no luck. I have a table (MktPrices) that has the following fields: BondID, PriceDate, Price. The objective is to allow the user to input a...
2
by: Pete | last post by:
Before I get started with the question, does anyone have a (single) good book recommendation for database design? Not an Access-specific book, but something geared toward helping me figure out...
3
by: John young | last post by:
I have been looking for an answer to a problem and have found this group and hope you can assist . I have been re doing a data base I have made for a car club I am with and have been trying to...
0
by: Jason | last post by:
I have a primary form which is used to enter/edit data in a table named Test_Results. On this primary form there is a subform which displays site addresses. This subform is linked to the primary...
6
by: Liz Malcolm | last post by:
Hello and Thanks in advance for any help. I am using Access 2000. I have a data entry form that opens a main form (using the On Click event of the combo box ) with tab controls and 1 subform on...
2
by: Smartin | last post by:
Using Access 97 I am trying to create a form that allows for user entry of search terms and displays a table of results. I thought I could accomplish this using a subform but it isn't quite...
8
by: GeorgeSmiley | last post by:
Does anyone know of a way, via VBA, to set the screen position of query results to a particular top, left position? I've glanced at API techniques but cannot find exactly what will do the trick....
30
by: Noob | last post by:
ftp://ukcassassin:winston@www.ukcassassin.pwp.blueyonder.co.uk/htdocs/Diary%20Form.bmp Hi all I will appologise in advance for my lack of knowledge of access and its working as i am quite new to...
1
by: christianlott1 | last post by:
I want to provide users with an interface to create a custom merge (all in Access, not Word). User will put in a set of brackets ("<>") in a memo field and when they click the merge button it will...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.