Field name parameter

  • Thread starter Thread starter Gwen Powell
  • Start date Start date
G

Gwen Powell

I am trying to write a simple piece of code that I will use over and over
again. I need to pass a field name as well as the table names to the code
but I cannot seem to get the syntax correct when trying to pass the field
name.

I have something like:
NumberThis(T1, T2, F1) 'F1 is the field name
Dim myTable, mySeed, myDB, myField
Set myDB=CurrentDB()
Set myTable=myDB.Openrecordset(T1)
Set mySeed=myDB.Openrecordset(T2)
Set myField=myTable.F1 '''This is where the problem is--I cannot remember
nor find the proper syntax
etc, etc

Thanks for any help.
Gwen Powell
Torrance Unified School District
 
Try this (assumes you're passing a string to the code where the string is
the name of the field):

Set myField=myTable.Fields("F1")
 
If F1 is a string variable containing a field name then I think this should
be:
Set myField=myTable.Fields(F1)
 
Back
Top