Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Searching Records in an Access Table on DBGRID

Posted on 1998-08-24
5
Medium Priority
?
152 Views
Last Modified: 2010-04-30
I want to search records just like you can in Excel in the same format.  I am using a DB Grid and have it linked to a data control.  I tried manipulating the MSVB5 Example of Findfirst,etc, and there was a problem in the data conversion of the two recordset types.  To sum it up I want  the user to search the first field in my 'table' and have this table updated so that, that matched record is highlighted.
0
Comment
Question by:qurashi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:blwatkins
ID: 1430676
How many records in the grid are you talking about?

How are you accessing the database?, (Datacontrol, etx?)

tell me if im correct in this statement?
  You want the user to type in a text box something to search for in one field?  Then press a search button and it will search the data and heighlight the row of data in your grid that matches his search text?

if above is correct let me know? and I will give exact details on how to achieve it?  If not correct my statement and I'll give details on that.

Thanks brad.

0
 
LVL 14

Expert Comment

by:waty
ID: 1430677
If I anderstand well, here is an answer

You don't have to use FindFirst, you should create a new query :

dim sSQL   as String
dim record as Recordset

sSQL = "Select Yourrecord From YourTable"
set record = DB.OpenRecordset(sSQL, DAO.dbOpenForwardOnly)
.

To update your table

sSQL = "Update YourTable Set yourSum = (Select Sum(Yourrecord) From YourTable)"

DB.Execute sSQL




0
 

Author Comment

by:qurashi
ID: 1430678
I should rephrase my question as I was quite vague.

I am working on a program that opens up a large database with many tables/queries.  These tables/queries are displayed on my DBGrid, and are changed when the user wants to view other information, eg. Customer Records as a table and Employee Records as a table.

I want the user to search the first field of the open table on the DBgrid.  When the record is found, I want the first field highlighted and the grid updated as such, just like working with a large MSExcel sheet.  

This searching will be accessed through a toolbar button, and will have a prompt.  

Thanks very much for a response!
0
 

Author Comment

by:qurashi
ID: 1430679
Wasn't what I was looking for, my fault as I was vague
0
 
LVL 1

Accepted Solution

by:
blwatkins earned 400 total points
ID: 1430680
The following is code related to searching thru a dbgrid to
find text that matches text put in by the user to search for.
The following code is attached to a "Search" Command button.


Private Sub Command1_Click()
Dim SearchVAL   As String
Dim Count       As Integer
Dim ISFound     As Boolean


  ISFound = False
  SearchVAL = InputBox("Enter Value to Find: ", "Find Record")
 
  DBGrid1.Col = 0
  For Count = 0 To Data1.Recordset.RecordCount - 1
    DBGrid1.Row = Count
    If DBGrid1.Text = SearchVAL Then
      ISFound = True
      Exit For
    End If
  Next
  If ISFound Then
    MsgBox "Found"
   Else
    MsgBox "Search Value was not Found!", vbInformation
  End If
End Sub

0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

618 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