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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Need Help with Filtering a Query/Report!!



 
 
Thread Tools Display Modes
  #1  
Old September 3rd, 2008, 03:57 PM posted to microsoft.public.access.queries
Eka1618
external usenet poster
 
Posts: 90
Default Need Help with Filtering a Query/Report!!

Hello,

I am trying to filter a subReport with query for a RecordSource (qryResults).

Here is the SQL for my the query:

SELECT tblResults.Q_INC, tblResults.SAMPLE_NO, tblResults.FAILED_AT,
tblResults.P_F, tblResults.FAIL_LEVEL, tblResults.ON_OFF,
tblResults.FAIL_TORQ, tblResults.PASS_VALUE, tblResults.TENSION,
tblResults.NOTES, tblResults.OBSERVATIONS, tblResults.L_PART_NO,
tblResults.K_PART_NO, tblResults.PAT_NO, tblResults.PAT_SIZE,
tblResults.FAIL_TRQ_LEVEL, tblResults.SHROUD_OVAL, tblResults.L_ID,
tblResults.K_ID, tblResults.L_FAILURE_MODE, tblResults.K_FAILURE_MODE
FROM tblResults;


The master/Child link is: Q_INC

When the subform loads I want it to filter in two different conditions:

If Me.Parent.K_ID.Value = Null Then
Me.RecordSource = "qryResults"
Me.Filter = "L_ID = " & Me.Parent!L_ID
Me.FilterOn = True
Else
Me.RecordSource = "qryResults"
Me.Filter = "L_ID = " & Me.Parent!L_ID And "K_ID = " & Me.Parent!K_ID
Me.FilterOn = True
End If


This code does not work, and I do not know what to do. I have tried many
other methods, I'm not sure what to do...

If anyone has any suggestion please let me know. Thank you!

--
~Erica~
  #2  
Old September 3rd, 2008, 09:10 PM posted to microsoft.public.access.queries
MGFoster
external usenet poster
 
Posts: 653
Default Need Help with Filtering a Query/Report!!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You have one error that I spotted:

Me.Filter = "L_ID = " & Me.Parent!L_ID And "K_ID = " & Me.Parent!K_ID

should be like this:

Me.Filter = "L_ID = " & Me.Parent!L_ID & " And K_ID = " & Me.Parent!K_ID

If the data types of L_ID and K_ID are Text then the line should be like
this:

Me.Filter = "L_ID = '" & Me.Parent!L_ID & "' And K_ID = '" & _
Me.Parent!K_ID & "'"

Note the single quote as the Text data delimiter.

My email formatter wrapped the line so I put in the VBA line extender
"_" (underline character) at the end of the line.

--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSL7vMYechKqOuFEgEQKFsgCgvuUQKeQjLbOsTj3zhyEm4/+uaD8An0GE
j9LFXXn9q+GKosZS6dB19Iu3
=7GAs
-----END PGP SIGNATURE-----

Eka1618 wrote:
Hello,

I am trying to filter a subReport with query for a RecordSource (qryResults).

Here is the SQL for my the query:

SELECT tblResults.Q_INC, tblResults.SAMPLE_NO, tblResults.FAILED_AT,
tblResults.P_F, tblResults.FAIL_LEVEL, tblResults.ON_OFF,
tblResults.FAIL_TORQ, tblResults.PASS_VALUE, tblResults.TENSION,
tblResults.NOTES, tblResults.OBSERVATIONS, tblResults.L_PART_NO,
tblResults.K_PART_NO, tblResults.PAT_NO, tblResults.PAT_SIZE,
tblResults.FAIL_TRQ_LEVEL, tblResults.SHROUD_OVAL, tblResults.L_ID,
tblResults.K_ID, tblResults.L_FAILURE_MODE, tblResults.K_FAILURE_MODE
FROM tblResults;


The master/Child link is: Q_INC

When the subform loads I want it to filter in two different conditions:

If Me.Parent.K_ID.Value = Null Then
Me.RecordSource = "qryResults"
Me.Filter = "L_ID = " & Me.Parent!L_ID
Me.FilterOn = True
Else
Me.RecordSource = "qryResults"
Me.Filter = "L_ID = " & Me.Parent!L_ID And "K_ID = " & Me.Parent!K_ID
Me.FilterOn = True
End If


This code does not work, and I do not know what to do. I have tried many
other methods, I'm not sure what to do...

If anyone has any suggestion please let me know. Thank you!


  #3  
Old September 4th, 2008, 11:35 AM posted to microsoft.public.access.queries
Eka1618
external usenet poster
 
Posts: 90
Default Need Help with Filtering a Query/Report!!

Thanks for the help Foster,

I ended up solving my problem using the method that Dale suggests in this
thread:

http://www.microsoft.com/communities...3-ba009e0e48b9

I knew that my quotes were probably wrong though... I was just really stuck
on this one. I'm not to great with reports yet, I'm still learning. Thank You!

--
~Erica~


"MGFoster" wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You have one error that I spotted:

Me.Filter = "L_ID = " & Me.Parent!L_ID And "K_ID = " & Me.Parent!K_ID

should be like this:

Me.Filter = "L_ID = " & Me.Parent!L_ID & " And K_ID = " & Me.Parent!K_ID

If the data types of L_ID and K_ID are Text then the line should be like
this:

Me.Filter = "L_ID = '" & Me.Parent!L_ID & "' And K_ID = '" & _
Me.Parent!K_ID & "'"

Note the single quote as the Text data delimiter.

My email formatter wrapped the line so I put in the VBA line extender
"_" (underline character) at the end of the line.

--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSL7vMYechKqOuFEgEQKFsgCgvuUQKeQjLbOsTj3zhyEm4/+uaD8An0GE
j9LFXXn9q+GKosZS6dB19Iu3
=7GAs
-----END PGP SIGNATURE-----

Eka1618 wrote:
Hello,

I am trying to filter a subReport with query for a RecordSource (qryResults).

Here is the SQL for my the query:

SELECT tblResults.Q_INC, tblResults.SAMPLE_NO, tblResults.FAILED_AT,
tblResults.P_F, tblResults.FAIL_LEVEL, tblResults.ON_OFF,
tblResults.FAIL_TORQ, tblResults.PASS_VALUE, tblResults.TENSION,
tblResults.NOTES, tblResults.OBSERVATIONS, tblResults.L_PART_NO,
tblResults.K_PART_NO, tblResults.PAT_NO, tblResults.PAT_SIZE,
tblResults.FAIL_TRQ_LEVEL, tblResults.SHROUD_OVAL, tblResults.L_ID,
tblResults.K_ID, tblResults.L_FAILURE_MODE, tblResults.K_FAILURE_MODE
FROM tblResults;


The master/Child link is: Q_INC

When the subform loads I want it to filter in two different conditions:

If Me.Parent.K_ID.Value = Null Then
Me.RecordSource = "qryResults"
Me.Filter = "L_ID = " & Me.Parent!L_ID
Me.FilterOn = True
Else
Me.RecordSource = "qryResults"
Me.Filter = "L_ID = " & Me.Parent!L_ID And "K_ID = " & Me.Parent!K_ID
Me.FilterOn = True
End If


This code does not work, and I do not know what to do. I have tried many
other methods, I'm not sure what to do...

If anyone has any suggestion please let me know. Thank you!



 




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 03:33 AM.


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