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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I Pass a Field as a paramter in a function

Status
Not open for further replies.

Dave1910

Programmer
Apr 21, 2002
2
GB
I need to be able to update any 1 of 3 fields in a table by using a function.
I have set the a recordset as below:
Set result=mybb.openrecordset("MYTABLE")
I find the record I need to update using

Result.findfirst Criteria
Then I need to be able to update 1 of 3 fields with following statement

result.edit
Result![VARIABLE]=Updated_data "... It is this field I need to update depending on the parameter passed in the function i.e. field names are Class1, Class2,Class3 "

Result.update
I tried passing the field name as a field in the function declartion
Any Ideas

 
I didn't see your Function statement but if it could just pass the name of the field you could simply use the following:
Code:
Result.edit
Select Case YourFunction()
   Case "Class1"
     Result![Class1] = Updated_data
   Case "Class2"
     Result![Class2] = Updated_data
   Case "Class3"
     Result![Class3] = Updated_data
end select
Result.update


If you want to pass just a value 1,2,3 then you could modify the Case statements to Case 1, Case 2, Case 3 etc.

If this is not what you are looking for just come back with more info.

Bob scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top