devxlogo

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

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Seasoned Architects Evaluate New Tech

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.