473,396 Members | 2,016 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,396 software developers and data experts.

The code to open the filtered form in report view is not woking

Hi Guys,

I am trying to open the filtered form in report view but I don't understand why it's not working. Could you please tell me where is the problem in my code ?

I just want to open the form in print preview and if I filtered something in that form then I want to open that filtered form in print preview also.

Here is my code.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Command25_Click()
  3.     Dim strSearch As String
  4.     Dim strText As String
  5.      'strText = Me.TxtBox.Value
  6.     If IsNull(Me.TxtBox.Value) Or Me.TxtBox = "" Then
  7.     MsgBox "Please type in your search keyword.", vbOKOnly, "Keyword Needed"
  8.     Me.TxtBox.BackColor = vbYellow
  9.     Me.TxtBox.SetFocus
  10. Else
  11.     strText = Me.TxtBox.Value
  12.     strSearch = "SELECT * from Qery_PVT_Demand_Forecast where ((Support_Status like ""*" & strText & "*"") or (BUOrgKey like ""*" & strText & "*""))"
  13.     Me.RecordSource = strSearch
  14.     Me.TxtBox.BackColor = vbWhite
  15. End If
  16. End Sub
  17.  
  18. ' Command to open the filtered Report in Print Preview
  19. Private Sub cmdOpenReport_Click()
  20.     DoCmd.OpenReport "[Rpt_PVT_Demand_Forecast]", acViewPreview, , Me.Filter
  21.     End If
  22. End Sub
  23.  
Dec 21 '15 #1

✓ answered by mbizup

Is your filter form' recordsource bound to "Qery_PVT_Demand_Forecast"? And is that spelled correctly? (it looks like you are missing a 'u' in "Qery').

Instead of setting the recordsource of the form try setting the filter property (since that is later read by your Open Report code). To set the filter, you just need the criteria (ie: the WHERE clause without the WHERE keyword).



Expand|Select|Wrap|Line Numbers
  1.     strSearch = "((Support_Status like ""*" & strText & "*"") or (BUOrgKey like ""*" & strText & "*""))"
  2.     Me.Filter = strSearch
  3.     Me.FilterOn = True 
  4.  

2 878
mbizup
80 64KB
Is your filter form' recordsource bound to "Qery_PVT_Demand_Forecast"? And is that spelled correctly? (it looks like you are missing a 'u' in "Qery').

Instead of setting the recordsource of the form try setting the filter property (since that is later read by your Open Report code). To set the filter, you just need the criteria (ie: the WHERE clause without the WHERE keyword).



Expand|Select|Wrap|Line Numbers
  1.     strSearch = "((Support_Status like ""*" & strText & "*"") or (BUOrgKey like ""*" & strText & "*""))"
  2.     Me.Filter = strSearch
  3.     Me.FilterOn = True 
  4.  
Dec 21 '15 #2
yes it's spelled correctly. My Supervisor gave the name like this "Qery".

Thank you so much for your help. It's working now.
Dec 21 '15 #3

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

Similar topics

1
by: edself | last post by:
I have a form which displays a subform datasheet of information. I'd like to be able to quickly click on a particular record and open up another form showing more detailed information about that...
1
by: Sagaert Johan | last post by:
Hi I made a control that in its onload sets the dockstyle to Fill, I only want this in runmode not in the IDE forms designer. Is there some attribute or define i can rely or use to prevent...
1
by: Ken | last post by:
I have a form that has a command button on it to open a report. The report is based on the forms data, if it's filtered the report is filtered, if the form is showing 100 records the report is...
9
by: angi35 | last post by:
Hi - In Access 2000, I'm trying to create a switchboard so users can open a certain form with different filters. I thought I would use an option group with toggle buttons. I suppose it could be...
2
by: TADEL714 | last post by:
I am trying to open a form based on the record set of the current form. The form I am opening should filtered based on a text field and a date field. The code I am using is as follows: Private Sub...
2
Daniel B
by: Daniel B | last post by:
I created a subform so that you could click an ID# and it would open another form with the information for that ID#. I would like to do the exact same thing, but open a report instead. The code i...
3
by: Neil Chinneck | last post by:
Hi everyone, I'm looking for some help please. I have a continuous form, with several fields which can be filtered using combo boxes. Once the user has filtered the form, I want them to enter...
0
by: baba | last post by:
DoCmd.OpenForm stDocName, acFormPivotChart I am using this statement to open a form in pivotchart view. Also, in the pivotchart view of the form,I dragged the columns that I needed for the...
5
by: Yousaf Shah | last post by:
Hello everybody. I am developing database for my patients. I have almost the needed stuff but now struck at report level. At the end of all required data entry, I want to give prescription to my...
5
by: GKJR | last post by:
I've been trying to figure this out for some time now to no avail. Is there any way to make a sub-report in a form or a report to show up as a print preview instead of the report view? There are...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
tracyyun
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...
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,...

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.