Check Field Names

Tanner65

Registered User.
Local time
Today, 17:09
Joined
Aug 31, 2007
Messages
66
I guess I'm having an off day today, nothing seems to be working for me, and now it's my for loops.

I need to go through each field in a table and return the names of those fields to determine what variables need to be set at.

Granted I'm not too familiar with Access, but I've tried all the .table stuff I can think of.

Edit: Now that I've updated the code, I'm coming up with a 3219 Run Time error, which says Invalid Operation at the beginning of the case selection.

Thus far my code consists of:
Code:
Sub WhichFieldNames(ByVal strTable As String)
Dim db As Database
    Dim tbl As TableDef
    Dim fld As Field
    Set db = CurrentDb
    Set tbl = db.TableDefs(strTable)
    For Each fld In tbl.Fields

        Select Case fld
          cases        
        End Select
    Next



End Sub

And even then it's some bastardized code I found somewhere in Google that doesn't work.

Thank in advance!

Stephen
 
Last edited:
Invalid Operation because fld is a field object.
What you need is the field's name property.

Select Case fld.Name

^
 
Invalid Operation because fld is a field object.
What you need is the field's name property.

Select Case fld.Name

^

Thanks EMP, not sure why I didn't see that, or hell even think of that option.
 

Users who are viewing this thread

Back
Top Bottom