New topic: 

[RESOLVED] Searching case sensitive or partial records

<http://forums.realsoftware.com/viewtopic.php?t=46354>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        rhartz          Post subject: [RESOLVED] Searching case 
sensitive or partial recordsPosted: Wed Dec 26, 2012 4:33 pm                    
     
Joined: Mon Feb 20, 2012 3:16 pm
Posts: 72                I'm trying to search records in a table that does not 
need to take into account capitalization and also to search a partial part of a 
field.  For example, the CustName field holds the customer's first and last 
name (Joe Smith).  Is it possible to just search "smith" (notice lowercase s) 
and pull up this record?

Here is my btnSearch code.  Typing in "Joe Smith" exactly how it appears in the 
field does pull up the record, but I'm looking to expand the search with not 
being so exact
dim sql as String

sql = "SELECT * FROM Registration WHERE RegCode = '" + txtSearch.Text + "' OR 
CustName = '" + txtSearch.Text + "' OR Email = '" + txtSearch.Text + "' ORDER 
BY RegCode"

dim rs as RecordSet = db.SQLSelect(sql)

while not rs.eof
  lbxReg.AddRow(rs.Field("ID").StringValue)
  lbxReg.Cell(lbxReg.LastIndex, 1) = rs.Field("RegCode").StringValue
  lbxReg.Cell(lbxReg.LastIndex, 2) = rs.Field("RegDate").StringValue
  lbxReg.Cell(lbxReg.LastIndex, 3) = rs.Field("CustName").StringValue
  lbxReg.Cell(lbxReg.LastIndex, 4) = rs.Field("Email").StringValue
  lbxReg.Cell(lbxReg.LastIndex, 5) = rs.Field("Product").StringValue
  rs.MoveNext
wend

rs.Close
     

    Last edited by rhartz on Wed Dec 26, 2012 5:25 pm, edited 1 time in total.  
 
                             Top                timhare          Post subject: 
Re: Searching case sensitive or partial recordsPosted: Wed Dec 26, 2012 5:11 pm 
                        
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11918
Location: Portland, OR  USA                Use " or CustName LIKE '%" + 
txtSearch.Text + "%' or ..."   
                             Top                rhartz          Post subject: 
Re: Searching case sensitive or partial recordsPosted: Wed Dec 26, 2012 5:25 pm 
                        
Joined: Mon Feb 20, 2012 3:16 pm
Posts: 72                Thanks Tim!  I forgot about the wildcard!   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to