devxlogo

Fast Database Lookups

Fast Database Lookups

Visual Basic doesn’t have a procedure like the DLookUp function that Access has. You can use thisprocedure in VB to receive the Name of an object by ID:

 Public Function MyDLookUp(Column As _        String, TableName As String, _        Condition As String) As VariantDim Rec As RecordsetOn Error GoTo MyDlookUp_Err' gCurBase is a global variable that ' holds the database that is currently ' openedSet Rec = gCurBase.OpenRecordset_        ("Select * From " & TableName)Rec.FindFirst ConditionIf Not Rec.NoMatch Then        ' return the requested field if         ' matching        MyDLookUp = Rec(Column)        Exit FunctionEnd If' return -1 if there is no match, or any ' other errorMyDlookUp_Err:        MyDLookUp = -1End Function
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist