troubleshooting Question

Testing for and Verifying Field Types and Widths in a linked DBF

Avatar of PBLack
PBLack asked on
Microsoft Access
7 Comments1 Solution471 ViewsLast Modified:
I have some code that is supposed to look through the fields in selected dbf table and test to make sure:

- the field name is right
- the field type is right
- the field width is right

I used the following and it worked when I just tested for field names but the type and fieldsize failed. I tired putting the field size in without quotes and it failed with an error:

field.fieldsize <invalid field data type>

I also had the "Char" type set to "Text" and that did not help.

The numeric I am not sure about either because the options can be float, double - any numeric type as long as it not integer or long integer. How can I test properly?

I do not know if it matters but the dbf comes from a GIS program that use dbf as its default file type. In the GIS software the text fields show up as Text in the properties after being created,  but when being created Text is not an available type, it is called string.

Numeric has the following types in it:

Short Integer
Long Integer
Double
Float

With either float or double acceptable.

Thanks

PBLack

   
 For Each fld In .Fields
        If fld.Name = "A" And fld.Type = "Char" And fld.FieldSize = "8" Then
            boolA = True
        ElseIf fld.Name = "B" And fld.Type = "Char" And fld.FieldSize = 2 Then
            boolB= True
        ElseIf fld.Name = "C" And fld.Type = "Numeric" Then
            boolC = True
        ElseIf fld.Name = "D" And fld.Type = "Char" And fld.FieldSize = 7 Then
            boolD = True
        ElseIf fld.Name = "E" And fld.Type = "Char" And fld.FieldSize = 20 Then
            boolE = True
        ElseIf fld.Name = "F" And fld.Type = "Char" And fld.FieldSize = 4 Then
            boolF = True
        ElseIf fld.Name = "G" And fld.Type = "Char" And fld.FieldSize = 1 Then
            boolG= True
        ElseIf fld.Name = "H" And fld.Type = "Char" And fld.FieldSize = 13 Then
            boolH= True
        ElseIf fld.Name = "I" And fld.Type = "Char" And fld.FieldSize = 200 Then
            boolI= True
        End If
    Next
ASKER CERTIFIED SOLUTION
als315

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros