Computing.Net > Forums > Database > Dynamic functions in Access 2003

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dynamic functions in Access 2003

Reply to Message Icon

Name: tinmanjo
Date: February 1, 2008 at 01:34:26 Pacific
OS: XP
CPU/Ram: 1024
Product: PC
Comment:

Im trying to implement a function in Access 2003 to allow the application to find a given field from a give another field in the same record. e.g.

I have a table of Assets called tblAssets, im trying to write a function that returns the AssetLabel from inputing the AssetID etc. The problem is i want to be able to find any record field based on another field inputed as a paramater and also allow other tables to be accessed.

Public Function WhatIs(FindPar As Variant, FromField As Field, ResultPar As Variant, ResultField As Field, rst As Recordset)

Set rstUnique = db.OpenRecordset(rst, dbOpenDynaset)


With rstUnique
.MoveFirst
Do

If FromField = FindPar Then
ResultPar = ResultField
End If

.MoveNext

Loop Until .EOF



End With

End Function


The function would be :-

WhatIs("Pc1", Field.AssetLabel, x, Field.AssetID, "tblAssets")


But this doesnt work argh.

Is this the right approach or is there a better way to define a dynamic function.


To succeed is to fail at least once.



Sponsored Link
Ads by Google

Response Number 1
Name: RugZ
Date: May 8, 2008 at 07:08:32 Pacific
Reply:

The parameter you pass as "rst" should not be an actual recordset object, but rather a string, because the database.OpenRecodset method, takes in the Recordset name as a string.

You can argue, fight and quarrel all you want, but at the end of the day you will have a headache


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: Dynamic functions in Access 2003

IIf Function in Access www.computing.net/answers/dbase/iif-function-in-access/439.html

summarising in access-using query www.computing.net/answers/dbase/summarising-in-accessusing-query/146.html

How to create a function in MS Acce www.computing.net/answers/dbase/how-to-create-a-function-in-ms-acce/328.html