Reference recordset field name with VBA (1 Viewer)

jkfeagle

Codus Confusious
Local time
Yesterday, 22:06
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?
 

boblarson

Smeghead
Local time
Yesterday, 19:06
Joined
Jan 12, 2001
Messages
32,059
rstOrders.Fields("Customer")
 

geekay

Registered User.
Local time
Today, 07:36
Joined
Aug 8, 2006
Messages
46
Why not rstOrders!Customer
 

edd

New member
Local time
Yesterday, 19:06
Joined
Feb 20, 2009
Messages
1
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

Top Bottom