• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

Delphi and MS Access lookup value

Hi Experts.

Is it possible to get the value of the row source of a MS Access table, inside Delphi?

If possible, how do I implement this value into my Delphi database project, using a normal ADOTable, DataSource and a DBGrid, or any other object.
1 Solution
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can use DAO to get to the properties of that table field:

Dim dbs As DAO.DAtabase
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim i As Integer

Set dbs = OpenDatabase("Path to your db")
Set tdf = dbs.TableDefs("YourTableName")
Set fld = tdf.Fields("YourFieldName")

For i = 0 to fld.Properties.Count
  If fld.Properties(i).Name = "RowSource" Then
    '/this is the RowSource value
  End If
Next i

Place ADOConnection1 on the form,link it to your MSAccess database using connection string :MS Jet 4 OLE DB provider, Place ADOTable and a Datasource on the form,link ADOTable to your ADOConnection1 (set the ADOConnection1 connected to true,loginprompt false)  ,Table name to your table name,datasource to your table and the grid to your datasource.simple...

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now