Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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
DoIf FromField = FindPar Then
ResultPar = ResultField
End If.MoveNext
Loop Until .EOF
End WithEnd 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.

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

![]() |
![]() |
![]() |

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