Solved

How to Look up data with DBGRID

Posted on 1998-01-14
9
180 Views
Last Modified: 2012-06-27
If I have a table with 2 fields, ID and NAME, how can I type the ID in the first column of the DBGRID and have the name shown automatically in the second column?
0
Comment
Question by:fury
[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
9 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1450995
You mean you need a source of a real time request?
(like if a user types 123 in the first row, the second row imediatly displays the corresponding name?)

Matvey
0
 

Author Comment

by:fury
ID: 1450996
am..I am talking about columns....
(like if a user types 123 in the first column, the second column immediatly displays the corresponding name
0
 
LVL 1

Expert Comment

by:oddau
ID: 1450997
If you use DBGrid, you can bind it to a DataControl that is connected with your database, and then you'll have both fields up, all the time...

If this is not what you want, I'd rather use a Textbox for the input, and then searched through the DB, and brought up the right row, containing the match.

What is it exactly you want to achieve with your program?

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:fury
ID: 1450998
I want it to be able to add student ID to the first column of the DBGRIB with the correspondent student name appears on the 2nd column...

not just one row...but multiple rows..of inserts...
0
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 50 total points
ID: 1450999
Bookmark the current row
Search the grid for the ID using .FindFirst
Get the name from the row you found and put it to the bookmarked row.
Set the bookmarked row to be the current one

Dim Book as Variant
Dim Text as string
Book = Data1.Recordset.bookmark
Text = Data1.Recordset("ID")
Data1.Recordset.FindFirst "ID=" & Text
Text = Data1.recordset("Name")
Data1.BookMark=Book
Data1.Recordset("NAME") = Text

0
 

Expert Comment

by:tapsbin
ID: 1451000
Hi Fury,

Meeting for the first time...i am new to the ring...

For your kind of programming i use sheridan grid...Add item...
method...At the input of a cell in dbGrid...I check into the
actual table....and if it exists...i display it from the table..
add it to the cell...and. ..then refreshed the dbGrid....this
way i can check ....

The another way of doing is i am attaching an Drop-Down combo
to the column of a Sheridan dbGrid...avoiding the display of
the name just to the right column of first column...

Please tell me further...if you want more explanation...

Awaiting to hear from you soon...

Thanks..

TAPS

0
 

Author Comment

by:fury
ID: 1451001
how can I create a empty temporary table and link it up with a datacontrol?
I tried:
datacontrol.RecordSource = "CREATE TABLE AddFund (Code TEXT(4), FNAME TEXT(50))"

but error occured....
do I need a database or ....?
I just want an table with defined fields
0
 

Expert Comment

by:tapsbin
ID: 1451002
Wait for a day...i will provide you with the sample for what i
mean to say using sheridan grid...

Thanks

TAPS

0
 

Expert Comment

by:tapsbin
ID: 1451003
dim dbDatabase as Database
dim rsRecordset as Recordset

dbDatabase = dbEngine.WorkSpaces(0).OpenDatabase("Database")
rsRecordset = dbDatabase.OpenRecordSet("Table")

Now...In the cell event of a sheridan data grid....

rsRecordset.Seek "=", ssdbGrid.Columns(0).Text
If Not NoMatch...

   ssdbGrid.Columns(1).Text = rsRecordset!Name
End If

Please give your feedback...

TAPS


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

752 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