473,385 Members | 1,838 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,385 software developers and data experts.

how to create search function in report wizard to search the data

64
This is the code for search button in form...

Expand|Select|Wrap|Line Numbers
  1. Dim lngID As String 
  2. If IsNull(Me.txtsearch) Then
  3. MsgBox "Please fill in RF No"
  4. ElseIf DCount("*", "QueryPane") = 0 Then
  5. MsgBox "Sorry, there is no such record"
  6. Me.txtsearch = ""
  7. Me.txtsearch.SetFocus
  8. Else
  9. lngID = Me.txtsearch
  10. DoCmd.OpenForm "Product_Requisition", acNormal, , "[RF_no]=" & lngID
  11. DoCmd.ClearMacroError
  12. End If
and it can be use

But the same coding use for my report wizard..
Expand|Select|Wrap|Line Numbers
  1. Dim lngID As String 
  2. If IsNull(Me.txtsearch) Then
  3. MsgBox "Please fill in RF No"
  4. ElseIf DCount("*", "QueryPane") = 0 Then
  5. MsgBox "Sorry, there is no such record"
  6. Me.txtsearch = ""
  7. Me.txtsearch.SetFocus
  8. Else
  9. lngID = Me.txtsearch
  10. DoCmd.OpenReport "Product_Requisition", acViewPreview, , "[RF_no]=" & lngID
  11. DoCmd.ClearMacroError
  12. End If
It cannot be use...
Mar 3 '15 #1
4 1167
twinnyfo
3,653 Expert Mod 2GB
First, in lines 10 of both blocks of code, you are trying to open a Form called "Product_Requisition" and an Report called "Product_Requisition". You cannot have both a Form and a Report by the same name in one project.

So, aside from knowing what you mean by "It cannot be use", and without knowing any error messages that you are receiving or knowing exactly what is not working, it is difficult to provide any specific solution at this time.

If you can provide some additional information we will be glad to help.
Mar 3 '15 #2
Brilstern
208 100+
mrijet,

#1 A good practice to avoid naming conflicts in Database items is to add a precursor to item names.

Personally I use this format:
Expand|Select|Wrap|Line Numbers
  1. frmName, Forms (where Name is the Form Name)
  2. rptName, Reports
  3. qryName, Queries
  4. tblName, Tables
  5. mdlName, Modules
  6. mcrName, Macro (although I rarely use Macros...)
#2
The Where statement "[RF_no]=" & lngID should be "[RF_no] = " & lngID (notice the spaces). That is just a formatting issue.

As far as why it isn't searching correctly. Are you receiving an error message? some clarification is needed to properly help you.

One thought is the difference between your form and report. Do they have the exact same data? Are the fields the same?

Code with suggested changes:
Expand|Select|Wrap|Line Numbers
  1. Dim lngID As String 
  2.  
  3.   If IsNull(Me.txtsearch) Then
  4.  
  5.     MsgBox "Please fill in RF No",vbOkOnly
  6.  
  7.   ElseIf DCount("*", "QueryPane") = 0 Then
  8.  
  9.     MsgBox "Sorry, there is no such record",vbOkOnlly
  10.     Me.txtsearch = ""
  11.     Me.txtsearch.SetFocus
  12.  
  13.   Else
  14.  
  15.     lngID = Me.txtsearch
  16.     DoCmd.OpenReport "Product_Requisition", acViewPreview, , "[RF_no] = " & lngID
  17.     DoCmd.ClearMacroError
  18.  
  19.   End If
Mar 5 '15 #3
mrijet
64
thanks for guiding me for the item names..and sorry for reply late...it seem doesn't have any error message but...

If I put the RF_no in the text box that have the data it will give go to this condition

Expand|Select|Wrap|Line Numbers
  1. ElseIf DCount("*", "QueryPane") = 0 Then
  2.  
  3.     MsgBox "Sorry, there is no such record",vbOkOnlly
  4.     Me.txtsearch = ""
  5.     Me.txtsearch.SetFocus
The data that I searching is actually got..but it seems not go to find the data...
Mar 11 '15 #4
twinnyfo
3,653 Expert Mod 2GB
We can only assume that your query QueryPane is searching correctly for the RF_No. How is QueryPane searching for this value? Could you post the SQL statement, as this may be at the heart of your searching problems?
Mar 11 '15 #5

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

Similar topics

1
by: nortelsale | last post by:
i have a site that allow people to post for sale, for rent info, I want to have advanced search function that can search all the posting (in my site) by zip code, and by certain miles say 10, 20...
2
by: gyromagnetic | last post by:
Hi, I have written a function that searches a text string for various words. The text is searched using a boolean 'and' or a boolean 'or' of the input list of search terms. Since I need to use...
1
by: Steven Spear | last post by:
Hi. I am trying to perform backtracking with this search function. Something is going wrong when I enter 2 at the command line. Entering 1 at the command line seems to work fine. I notice that...
0
by: Lisa Henkel | last post by:
In Access 2000, does anybody know how to write code behind a button, in such a way that the Report Wizard runs when you press the button? I'd really like to use the standard Report Wizard if I can...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
5
by: Greg Teets | last post by:
I am running an Access report from VB via ADO. The report has a field that shows the date it was run. How can I return the data from this field to VB or have Access post it to a table when the...
0
by: Net | last post by:
Hi, I need to create a VB.Net search function against an Access database. When the user enters a character the function should search last name and the tree listview needs to be updated to show...
3
markmcgookin
by: markmcgookin | last post by:
Hi Folks, I have a VB app, and I have been working at it for a while, and I am now at the stage where I want to create a search function. Now don't be scared! It is in the .Net compact framework,...
1
by: Coolboy55 | last post by:
I'm sure this can't be as difficult as it seems, but I'm trying to create a simple chart in a report in Access 2003. The report is based on a query and I'd like to display the data in a chart. Any...
8
by: michaeldebruin | last post by:
I am trying to give my program a search function which can search for directories. At the moment it can search for directories but it's only searching for the directories who have exactly the name...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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...
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...

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.