Solved

SQL Problem and clearing FlexGrid

Posted on 1999-01-26
6
165 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
Comment Utility
Half an answer:

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

WHERE YourNameField LIKE '%bil%'
0
 
LVL 10

Expert Comment

by:caraf_g
Comment Utility
To clear your flex grid:

YourFlexGrid.Clear
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 50 total points
Comment Utility
Erm... I think that might answer your question
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:winson
Comment Utility
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
Comment Utility
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
Comment Utility
Close
Malaysia
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

743 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

16 Experts available now in Live!

Get 1:1 Help Now