help writing fields to table definition (1 Viewer)

gammaman

Registered User.
Local time
Today, 12:05
Joined
Jun 3, 2013
Messages
16
I am trying to write some fields to an access table definition. It is working for the most part except that I want to write some of the fields as dbText and others as dbDate. For some reason it is writing all of them as dbDate and I don't know why.

Code:
additionalColumns = Array("a","b","c","d","e","f")

'add additonal columns to report
For i = LBound(additionalColumns) To UBound(additionalColumns)
MsgBox additionalColumns(i)
If additionalColumns(i).Value = "a" OR "b" Then
Set columnNames = xlsht.Cells(1, additionalColumns(i))
Set FieldName = tb1.CreateField(additionalColumns(i), dbDate, 10)
tb1.Fields.Append FieldName
Else
Set columnNames = xlsht.Cells(1, additionalColumns(i))
Set FieldName = tb1.CreateField(additionalColumns(i), dbText, 150)
tb1.Fields.Append FieldName
End If
Next i
 

pr2-eugin

Super Moderator
Local time
Today, 20:05
Joined
Nov 30, 2011
Messages
8,494
Hello gammaman, Welcome to AWF.. :)

Your If condition is off.. Try this..
Code:
If additionalColumns(i) = "a" OR [B]additionalColumns(i) = [/B]"b" Then
 

gammaman

Registered User.
Local time
Today, 12:05
Joined
Jun 3, 2013
Messages
16
OMG. I can't believe I forgot that. Do you know how long this has been driving me crazy. LOL.
 

pr2-eugin

Super Moderator
Local time
Today, 20:05
Joined
Nov 30, 2011
Messages
8,494
Ha ha.. Glad you have it sorted.. Good Luck.. :)
 

Users who are viewing this thread

Top Bottom