Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7775879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:44:11+00:00 2026-06-01T17:44:11+00:00

Hi I need some help in creating a template function (as they are known

  • 0

Hi I need some help in creating a template function (as they are known in c++ if I’m correct). I’m using Delphi XE2, and I’m writing a database application using an MS Access database.

The problem is that there is a lot of functions that I write that does the same thing on different tables. So I thought that I can create template functions and then just use different parameters for the different tables.

For example, there is the Locate function that locates a specific record in a table or query. Now I would like to make a template function of this but I do not know how to do this.

I want to put the function in the public section of my datamodule, so I was thinking in the line of this

function find(tableName: TADOTable, fieldName: String, fieldValue: String):Boolean

Then…

function TDataModule.find(tableName: TADOTable, fieldName: String, fieldValue:String): Boolean;
var SearchOptions : TLocateOptions;
 begin
  SearchOptions := [loCaseInsensitive]; 
  find := DataModule.tableName.Locate('fieldName', fieldValue, SearchOptions);
 end;

But this do not want compile…

It there any way to make some kind of template function where I can pass any table as a parameter or would it be beter to create a class for every single table, with getter and setter functions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:44:12+00:00Added an answer on June 1, 2026 at 5:44 pm
    function TDataModule2.LocateData(AADOTable: String; AKeyFields: String; 
      AKeyValues: Variant; Options: TLocateOptions): Boolean;
    var
      oComp: TComponent;
    begin
      Result := False;
      oComp := FindComponent(AADOTable);
      if (oComp is TADOTable) and (oComp as TADOTable).Active then
        Result := (oComp as TADOTable).Locate(AKeyFields, AKeyValues, Options);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help in creating function which can create folders recursively with giving path:
I need some help on creating a function similar to the putenv() function of
I need some help creating a function which does the same thing for the
I need some help with creating an insert statement for an Access 2007 database
I need some help creating a query for my mySQL database. I have recently
I need some help in creating report using iReport for this layout. I am
Once again I need some help. I'm creating a multiple file upload function with
I need some help creating a regular expression. I need to get all the
i need some help with creating file Im trying in the last hours to
need some help with retrieving information+Profile pic from twitter using php , i wanted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.