Hi.
Im trying to program my radio buttons to filter data for student pass/fail in a sub form called [front screen data] I have using help found here got this far but its not working and Im not sure why. my radio buttons are as follow
#1 pass
#2 fail
#3 both
my field is [PassFail]
This is what i have
Private Sub Frame29_BeforeUpdate(Cancel As Integer)
Select Case Me!Frame29
Case 1
Me.Filter = "Pass or Fail = Pass"
Me.FilterOn = True
MsgBox "Pass or Fail = Pass"
Case 2
Me.Filter = "Pass or Fail = Fail"
Me.FilterOn = True
MsgBox "Pass or Fail=Fail"
Case 3
Me.FilterOn = False
MsgBox "Show All Records"
End Select
End Sub
Any help would be appreciated
Thanks
Hi. Firstly, you'll need to use the AfterUpdate event of your frame, not its BeforeUpdate event. Secondly, if the field you are filtering on is called Pass or Fail you will need to enclose the field name in brackets, like this: [Pass or Fail]. Thirdly, the text values 'Pass' and 'Fail' must be enclosed in quotes: - Private Sub Frame29_AfterUpdate()
-
Select Case Me!Frame29
-
Case 1
-
Me.Filter = "Pass or Fail = Pass"
-
Me.FilterOn = True
-
Case 2
-
Me.Filter = "Pass or Fail = Fail"
-
Me.FilterOn = True
-
Case 3
-
Me.FilterOn = False
-
End Select
-
End Sub
-
If the frame (and consequently its AfterUpdate event code) is on the main form you will need to refer to the subform specifically, whereas at present the code above may be referring to the main form. If you need to filter the subform from the main form, the syntax is - Me![YourSubformControlName].Form.Filter = "[Pass or Fail] = 'Pass'"
-
Me![YourSubformControlName].Form.FilterOn = ***
(Of course you would need to substitute the actual name of your subform control for the placeholder in the example above.)
-Stewart
11 5740
Hi. Firstly, you'll need to use the AfterUpdate event of your frame, not its BeforeUpdate event. Secondly, if the field you are filtering on is called Pass or Fail you will need to enclose the field name in brackets, like this: [Pass or Fail]. Thirdly, the text values 'Pass' and 'Fail' must be enclosed in quotes: - Private Sub Frame29_AfterUpdate()
-
Select Case Me!Frame29
-
Case 1
-
Me.Filter = "Pass or Fail = Pass"
-
Me.FilterOn = True
-
Case 2
-
Me.Filter = "Pass or Fail = Fail"
-
Me.FilterOn = True
-
Case 3
-
Me.FilterOn = False
-
End Select
-
End Sub
-
If the frame (and consequently its AfterUpdate event code) is on the main form you will need to refer to the subform specifically, whereas at present the code above may be referring to the main form. If you need to filter the subform from the main form, the syntax is - Me![YourSubformControlName].Form.Filter = "[Pass or Fail] = 'Pass'"
-
Me![YourSubformControlName].Form.FilterOn = ***
(Of course you would need to substitute the actual name of your subform control for the placeholder in the example above.)
-Stewart
Thanks sooooo much. This worked perfectly. I had tried to put the field name in brackets but when I did this i removed the speech marks causing an error. Didnt think about the quotation marks though.
Also thought about the subform bit but tried to add that to [frontend subform]![pass or fail] so didnt work. This worked perfectly. I am forever grateful
Jody
Ok so just noticed something...added the syntax just before the select case me part and now when I use the form it sort of works.
The screen when I press pass works fine and shows all that have passed but when I select fail the subform refreshes but remains the same (showing all passed) so when I select Both the same happens (showing all passed)
any ideas???
Not sure; I'd suggest that you add the following statement just after the End Select statement to provide some state tracing of what is going on: - msgbox "Button value: " & Me!Frame29 & " - Filter: " & Me.Filter & " - Filter Status: " & IIF(Me.FilterOn, "On", "Off")
If, as I suspect is the case, the filter is being applied as expected then the problem is in the relationship between your main form and your subform in some way or another.
If the filter shown in the messagebox is not as expected you will need to check the context of the button value and the case statement involved.
-Stewart
As suspected when the filter is selected the pop up says the filter status is off. Do you have any suggestions??
I am unsure where to go as I am not a novice but I am also not an expert. I have some knowledge but apparently not enough.
Any advice you have is gratefully received.
If you could post the whole of the current AfterUpdate code I'll check the syntax for you.
Please be aware that filtering the main form will in no way affect the subform's records.
-Stewart
This is what I have now completely. I added in some requery's to updat it each time to check if that was the problem so here is everything I got
Private Sub Frame29_AfterUpdate()
Me![front screen data subform].Form.Filter = "[Pass or Fail] = 'Pass'"
Me![front screen data subform].Form.FilterOn = True
Select Case Me!Frame29
Case 1
Me.Filter = "[Pass or Fail] = 'Pass'"
Me.FilterOn = True
MsgBox "You have requested to view students who have Passed only"
Forms![Front Screen]![front screen data subform].Requery
Case 2
Me.Filter = "[Pass or Fail] = 'Fail'"
Me.FilterOn = True
MsgBox "You have requested to view students who have Failed only"
Forms![Front Screen]![front screen data subform].Requery
Case 3
Me.Filter = ""
Me.FilterOn = False
MsgBox "You have requested to See All Records"
Forms![Front Screen]![front screen data subform].Requery
End Select
MsgBox "Button value: " & Me!Frame29 & " - Filter: " & Me.Filter & " - Filter Status: " & IIf(Me.FilterOn, "On", "Off")
End Sub
Thanks
Problem is that in your Select Case statement you are applying filtering to the main form, not to the subform. The statements you added before the Select Case apply a filter to the subform - the case statement is having no effect as it is filtering the main form only.
I'd replace the AfterUpdate code as follows: - Private Sub Frame29_AfterUpdate()
-
Select Case Me!Frame29
-
Case 1
-
Me![front screen data subform].Form.Filter = "[Pass or Fail] = 'Pass'"
-
Me![front screen data subform].Form.FilterOn = True
-
MsgBox "You have requested to view students who have Passed only"
-
Case 2
-
Me![front screen data subform].Form.Filter = "[Pass or Fail] = 'Fail'"
-
Me![front screen data subform].Form.FilterOn = True
-
MsgBox "You have requested to view students who have Failed only"
-
Case 3
-
Me![front screen data subform].Form.Filter = ""
-
Me![front screen data subform].Form.FilterOn = False
-
MsgBox "You have requested to See All Records"
-
End Select
-
MsgBox "Button value: " & Me!Frame29 & " - Filter: " & Me![front screen data subform].Form.Filter & " - Filter Status: " & IIf(Me![front screen data subform].Form.FilterOn, "On", "Off")
-
End Sub
There is no need for the requery statements, as turning the filter on or off requeries the subform automatically.
-Stewart
Thank you soooo much. This has been bugging me for over 3 days before I sent you the message so I really welcome this.
Thanks
Hi again,
This has been working fine but Im trying to use a DCount to count the records in my subform based on my selections using a my drop downs but for some reason it doesnt work based on my selections using the radio buttons.
This is the code I have added (after the End Select)
[Text54] = DCount("[Surname]", "front screen data")
Any ideas why this isnt working??(it isnt updating in the DCount box)
Thanks
Although you are posing a different question - which should be in its own thread - DCount is a very simple function which does what it is asked to do. A quick way to check what is going on is to replace your current line with this one:
Msgbox "Rows in front screen data: " & DCount("*", "front screen data")
This will show you the value of the number of rows in table or query front screen data. If this value is 0 then there are no rows in that data source.
I cannot tell you more about what to check given that I know nothing at all about what the datasource 'front screen data' is or how it is updated.
-Stewart
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Newbie |
last post by:
I currently have a set of simple calculations to determine square footage
and multuply that by a dollar amount per foot. I use form fields that are
filled in by the user, and then the Submit...
|
by: sman |
last post by:
Hi, I recently read this article on About.com on how to create
required fields for a form:
http://javascript.about.com/library/scripts/blformvalidate.htm
Everything works great except that there...
|
by: DettCom |
last post by:
Hello,
I would like to be able to display or hide fields based on whether a
specific Yes/No radio button is selected. This is in conjunction with
a posting a just made here in the same group...
|
by: Glenn |
last post by:
I have a datagrid which i have added a extra template column to which
was a radio button in it.
The end user should use the radio button to select one of the items and
then click a button to...
|
by: shror |
last post by:
i want to add a midi file to my pages and i want to put two radio
buttons so that on is on and the other is off so that the users can
start or stop the file playing by choosing one of the radio...
|
by: worldapps |
last post by:
Hi,
Can any one help me in my fallowing tasks.
1) I have Table po_headers in that i have two columns like po_number,
po_type
In my form Layout I have to take
|
by: Eric |
last post by:
Hi. I have this Combobox name 'Origin' that contains all states and
countries. I would like to create two Radio buttons (State and
Country) that when you select State, the combobox will query only...
|
by: eeffoc |
last post by:
I've got a set of six radio buttons inside of a list box and what I'm trying to accomplish is generate a random number all with different ranges (Dice for d&d) depending on what radio button is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
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...
| |