Solved

SQL Problem and clearing FlexGrid

Posted on 1999-01-26
6
168 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

932 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now