Reference recordset field name with VBA

jkfeagle

Codus Confusious
Local time
Today, 14:26
Joined
Aug 22, 2002
Messages
166
Does anyone know how to reference the field name through VBA code? For example the table the recordset (rstOrders) is based on has a field named Customer. How do I reference that in VBA?
 
rstOrders.Fields("Customer")
 
What if I wanted to use !Customers as a paramater for some function, but its possible that the table does not contain that particular field?

example

with rst
' some code
value = someFunction (param1, param2, !Customers)
end with

However, sometimes !Customers is not part of rst in every case. (users can choose which fields they want)
I tried using an IIF to check if the table had the field, looked something like

'(hasfield() is a function written by my predecessor)
value = somefunction(param1, param2, _
IIF(hasField (theTable, Customers), !Customers, "")
This did not work, always got "Not found in collection" for !Customers

Any ideas?
Thanks
 

Users who are viewing this thread

Back
Top Bottom