Solved

SQL Problem and clearing FlexGrid

Posted on 1999-01-26
6
170 Views
Last Modified: 2010-05-03
I have problem search an name that been enter and list out the name in that consist a particular string such as
 *bil*
How do we do this in SQL ? Following Are my source code

One more thing is how do i clear the FlexGrid if i like to empty it
 
Dim daorst As Recordset
Dim daodb As Database
Dim sSql As String
Dim x As Long
Set daodb = OpenDatabase("C:\Program Files\DevStudio\VB\TK2073\project2073.mdb")
sSql = "SELECT * FROM Makpel" & _
       " WHERE Makpel.nama = " & _
       Chr(34) & nama_s & Chr(34) & _
       " OR Makpel.nomatriks = " & _
       Chr(34) & nomatriks_s & Chr(34) & _
       " OR Makpel.alamatsemasa = " & _
       Chr(34) & alamat_s & Chr(34) & _
       " OR Makpel.namawaris = " & _
       Chr(34) & namawaris_s & Chr(34) & _
       " ORDER BY nama;"
Set daorst = daodb.OpenRecordset(sSql)
      With daorst
         Do While Not .EOF
         x = x + 1
         MSFlexGrid.AddItem .Fields("nama").Value & Chr(9) & _
         .Fields("nomatriks").Value & Chr(9) & _
         .Fields("namawaris").Value & Chr(9) & _
         .Fields("status").Value & Chr(9) & _
         .Fields("alamatsemasa").Value & Chr(9) & _
         .Fields("fakulti").Value & Chr(9) & _
         .Fields("jabatan").Value & Chr(9) & _
         .Fields("tahun").Value & Chr(9) & _
         .Fields("alamattetap").Value & Chr(9), x
         .MoveNext
0
Comment
Question by:winson
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 1470730
Half an answer:

To find names that have "bil" in them, use

WHERE YourNameField LIKE '%bil%'
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1470731
To clear your flex grid:

YourFlexGrid.Clear
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 50 total points
ID: 1470732
Erm... I think that might answer your question
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:winson
ID: 1470733
the problem is that the nama_s in my sql is a variable
so if i  WHERE Makpel.nama Like '*nama_s*' it does NOT work
but if i WHERE Makpel.nama Like '*bil*' it's  working
and list all the word with *bil*
but the fact is nama_s = bil
pls HELP
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1470734
Use a string variable

Dim strSQLWhere As String

strSQLWhere = "WHERE Makpel.nama Like '*" & nama_s & "*'"

Good luck.

PS - just out of curiosity... what country are you from? I'm trying to guess but my best guess is Indonesia, please forgive me if I'm wrong!
0
 

Author Comment

by:winson
ID: 1470735
Close
Malaysia
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 65
VBA/SQL - Connect to SQL server and pull data 4 119
how to know if my Checkbox is True in VB6.0? 9 60
Problem to line 23 55
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question