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

Search Form Doesn't work

Hi everyone,

I had made a search form in ACCESS with some coding from internet. However, i noted that if some field is blank, it will not able to search any result even if it is found in the database. Would anyone help?

Form layout is under the following link
http://www.geocities.com/richie_ccs/form.bmp

Coding from internet (Allen Browne)

If Not IsNull(Me.Worktype) Then
strWhere = strWhere & "([dbo_W20U999S].[ENDWRKTYPE] = """ & Me.Worktype & """) AND "
End If
If Not IsNull(Me.StatCD) Then
strWhere = strWhere & "([dbo_W20U999S].[ENDSTATCD] = """ & Me.StatCD & """) AND "
End If
If Not IsNull(Me.FunCode) Then
strWhere = strWhere & "([FNCD].[DATAVALUE] = """ & Me.FunCode & """) AND "
End If
If Not IsNull(Me.FromDate) Then
strWhere = strWhere & "([dbo_W20U999S].[CRDATTIM] > """ & Me.FromDate & """) AND "
' strWhere = strWhere & "([EnteredOn] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "

End If

If Not IsNull(Me.ToDate) Then 'Less than the next day.
strWhere = strWhere & "([dbo_W20U999S].[CRDATTIM] < """ & Me.ToDate & """) AND "

End If

lngLen = Len(strWhere) - 5
'MsgBox (lngLen)
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)
DoCmd.OpenQuery ("Query1")
End If

Also i wonder if i want to add some more feature like under worktype field, i want to input criteria "test" or "test1", it will come out the result with either test or test1, what can i do?

Thank you very much for help!!

Cherrie
Jun 6 '07 #1
1 1438
maxamis4
295 Expert 100+
Simply put your logic is right. You use the key word "AND". This means that unless all conditions are true no results will show up. You should try maybe using or instead. That might maxamize your output. Also google wild cards, I have found that with search queries they are essentially the best.
Jun 6 '07 #2

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

Similar topics

7
by: WindAndWaves | last post by:
Hi Gurus I am keen to make a search page on a website, but I have absolutely zero experience with PHP. I am going to hire an expert, but I thought that it may pay to try it a bit first myself...
8
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
1
by: aps-asia | last post by:
I have one WinForm and 3 buttons on this form. all buttons are private. I set the button2's click event to execute the "Controls.RemoveByKey("button1");". When I executed the button2's click...
5
by: DFS | last post by:
This works pretty well, and it's easy, but it's not the ultimate solution. The kludgey part is it uses a hidden field to incrementally capture the keystrokes in the visible field (because executing...
4
by: jl2886 | last post by:
LSI Case Number is an ID. It is constructed by "the month (1 or 2 digits) &theyear(2digits) & "-" & three digit number. I want to create a search for it on a form. In the following code the...
10
by: jonathan184 | last post by:
Hi I tried getting this to work through dreamweaver but it did not. So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me...
1
by: hottoku | last post by:
Hi All, I'm having quite a bit of trouble designing a search tool to work with my database. I have found lots of examples from Microsoft Templates to Allen Browne's sample search form. The...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
13
by: Robertf987 | last post by:
Hi, Yet another thing I need help with I'm affraid. I'll first explain what I want, then I'll try to explain what I have. I'm using Microsoft Access 2000. What I want is to be able to do a...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...

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.