Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing field name as a parameter

Status
Not open for further replies.

ormsk

Programmer
Sep 30, 2002
147
GB
Hi

I want to be able to create a dynamic function that returns true/false whether a record exists in a table or not.

I am trying to pass 3 params (tblToSearch,varToSearchFor,fieldName)

tblToSearch = table / query name
varToSearchFor = string or integer etc
fieldName = name of field

It is the name of field I am having problems with as I need to incorporate the ! operator, but cannot get Access to evaluate without generating an error.

Any ideas anyone?


Regards Why did kamikazi pilots wear helmets?
 
Please show us the code you have... I think that'll help us help you...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
I am not sure if this is helpfull,but I think it's worth trying these lines
private function Exists(tblToSearch,varToSearchFor,fieldName) as boolean

dim rst as new adodb.recordset
with rst
.cursorlocation=aduseclient
.open tblToSearch,currentproject.connection,adopendynamic
.find "fieldName='varToSearchFor'"

if rst.eof then 'It doesn't exist
Exists=False
else 'It exists
Exists=True
end if
end with

I know that it could be more than just these lines, but I hope it will help you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top