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

Search returns error message

418 256MB
Hello!

I am trying to use a search button to find : 1) VendorName and/or 2)InvoiceNo. One is working while the other is not. When I look for an invoice number, it works but when I try to find a vendor, it does not. The combo box does not list the vendor names as it should. And when I try to type a vendor name I get error message that reads: "The text you entered isn't an item in the list..."

What am I doing wrong? Can anyone please help? Thanks.

The main form is called frmFIND and the subform is called sfrmFindAP which is based on a query. The name of the query is qryAP which is working just fine.


frmFIND has this unbound combo box called cboVendor


Row Source: cboVendor
Expand|Select|Wrap|Line Numbers
  1. SELECT 0 as VendorID,
  2.        "<ALL>" as VendorName
  3.  
  4. FROM tblzNull
  5.  
  6. UNION ALL
  7. SELECT tblVendors.VendorID,
  8.        tblVendors.VendorName
  9.  
  10. FROM tblVendors;
cmdFIND
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFIND_Click()
  2.   ' Update the record source
  3.     Me.sfrmFindAP.Form.RecordSource = "SELECT * FROM qryAP " & BuildFilter
  4.  
  5.     ' Requery the subform
  6.     Me.sfrmFindAP.Requery
  7. End Sub
And here is my code:
Expand|Select|Wrap|Line Numbers
  1. Private Function BuildFilter() As Variant
  2.     Dim varWhere As Variant
  3.     Dim varItem As Variant
  4.     Dim intIndex As Integer
  5.  
  6.     varWhere = Null  ' Main filter
  7.  
  8.  
  9.     ' Check for LIKE InvoiceNo
  10.     If Me.txtInv > "" Then
  11.         varWhere = varWhere & "[InvoiceNo] LIKE ""*" & Me.txtInv & "*"" AND "
  12.     End If
  13.  
  14.     ' Check for VendorName
  15.     If Me.cboVendor > 0 Then
  16.         varWhere = varWhere & "[VendorName] = '" & Me.cboVendor.Column(1) & "' AND "
  17.     End If
  18.  
  19.  
  20.     ' Check if there is a filter to return...
  21.     If IsNull(varWhere) Then
  22.         varWhere = ""
  23.     Else
  24.         varWhere = "WHERE " & varWhere
  25.  
  26.         ' strip off last "AND" in the filter
  27.         If Right(varWhere, 5) = " AND " Then
  28.             varWhere = Left(varWhere, Len(varWhere) - 5)
  29.         End If
  30.     End If
  31.  
  32.     BuildFilter = varWhere
  33.  
  34. End Function
Apr 28 '09 #1
6 1581
ChipR
1,287 Expert 1GB
Try your combo box with just the RowSource
Expand|Select|Wrap|Line Numbers
  1. SELECT tblVendors.VendorID, tblVendors.VendorName FROM tblVendors
and see if that works first. It looks like you want it bound to column 1 and displaying both or only the second column.
Apr 28 '09 #2
MNNovice
418 256MB
ChipR:

It's working after I made the changes you suggested. Here is where I am puzzled. The same logic I used in my frmFIND on another DB, it worked just fine. What was I doing wrong here? Just curious to know. Thanks for your help.
Apr 28 '09 #3
ChipR
1,287 Expert 1GB
The cmd_FIND code looked absolutely fine to me, but the RowSource was suspicious, since the combo was not listing the names properly. Do you have a tblzNull?
Apr 28 '09 #4
MNNovice
418 256MB
ChipR:

That's it!!! Wow!. You're so smart. How could I completely forget about that important little thing. Now I know. Thank you.
Apr 28 '09 #5
NeoPa
32,556 Expert Mod 16PB
Am I right to think that [tblzNull] is a table whose reason is simply to provide a dummy source for such literal values?

If so, remember that you can use the following with very little extra overhead :
Expand|Select|Wrap|Line Numbers
  1. SELECT TOP 1
  2.        0 as VendorID,
  3.        "<ALL>" as VendorName
  4. FROM tblVendors
  5.  
  6. UNION ALL
  7. SELECT VendorID,
  8.        VendorName
  9. FROM tblVendors
In each case simply reuse the same table as is already to be used in the other SELECT query.
Apr 29 '09 #6
MNNovice
418 256MB
NeoPa:

Yes, you are right. I was missing the tblzNull which caused the problem. It's resolved now.

Thanks for the new tip.
Apr 29 '09 #7

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

Similar topics

1
by: arikatla | last post by:
We are using SQL Server 2000 database (with sp3) and recently we faced an interesting issue with full text search. According to SQLServer help page "AND | AND NOT | OR Specifies a logical...
16
by: Stanley Sinclair | last post by:
Bear with me. I am being very calm; took a Valium. I have waited two weeks to write this, because every time I wrote it before the message was, at best, nasty. I need to use the services of...
8
by: ignatova | last post by:
Hello, I have been using IBM Net Search Extender to perform full text searches on text columns in relational tables in DB2 without any problems until now. However it doesn't seam to function...
6
by: richard | last post by:
http://safer.fmcsa.dot.gov/CompanySnapshot.aspx How could I go about automating a search of this site's database? I'm not interested in all the details they present on the output form, just...
4
by: BenCoo | last post by:
Hello, In a Binary Search Tree I get the error : Object must be of type String if I run the form only with the "Dim bstLidnummer As New BinarySearchTree" it works fine. Thanks for any...
16
by: Computer geek | last post by:
Hello, I am new to VB.NET and programming in general. I have taught myself a lot of the basics with vb.net but am still quite the novice. I am working on a little application now and I need some...
14
by: Simon Gare | last post by:
Hi, have a search.asp page with results.asp page drawing data from an SQL db, problem is the user has to type the whole field value into the search box to retrieve the value on results.asp, what...
9
by: AMBLY | last post by:
Hello ! Hope someone might be able to help me with this one. I run Access2000 on XP. I have a form : frmONE- which contains a txt field: ctrCTN from my table/database. The values in ctrCTN are...
3
by: mercuryshipzz | last post by:
#!/usr/bin/perl #use strict; use warnings; sub search_pattern { my $file_name = $_;
1
by: thesinik | last post by:
import random import math t = tuple() def linsearch(key, l): count = 0 index = 0 t = tuple() for i in l:
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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
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
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.