This is my function to get the size of a varchar field of a SQL-Server table used in access via ODBC:
Function fn_field_size(par_tab, par_field As Variant) As Variant
Dim db_tab As DAO.Database
Dim tab_tab As DAO.TableDef
Dim tab_field As DAO.field
fn_field_size = 0
Set db_tab = CurrentDb()
Set tab_tab = db_tab.TableDefs(par_tab)
Set tab_field = tab_tab.Fields(par_field)
fn_field_size = tab_field.Size
Set tab_tab = Nothing
Set db_tab = Nothing
End Function
It seemed to work fine until I used the function for a varchar(1000) field. In this case tab_field.Size is 0. With smaller fields like Varchar(100) the function works fine and returns 100.
Why is this?