Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modify Field Type in VB 1

Status
Not open for further replies.

fredka

Technical User
Jul 25, 2006
114
0
0
US
I have some code that adds a field to a table. (see below) I am trying to figure out how to make the field an integer.

Any help would be greatly appreciated!!! thanks!!

Fred

Dim db As Database
Dim tbl As TableDef
Dim fld As DAO.Field
Dim finDate As String
Dim filename As String
filemname = [Forms]![frmUpdateFinancedata]![financefiledate] & "Mbrs"

If IsNull(Me.financefiledate) Or Me.financefiledate = "" Then
MsgBox "please enter a date for the most recent finance file"
Else
'assign date on form to variable to create field name
finDate = [Forms]![frmUpdateFinancedata]![financefiledate]
Set db = CurrentDb()
Set tbl = db.TableDefs("tblFinanceNumbers")
Set fld = tbl.CreateField(finDate & "Mbrs", dbText, 30)
tbl.Fields.Append fld
MsgBox "Done"
End If
CleanUp:

Set fld = Nothing
Set tbl = Nothing
Set db = Nothing

Exit Sub
 
Change this line:

Set fld = tbl.CreateField(finDate & "Mbrs", dbText, 30)

To:

Set fld = tbl.CreateField(finDate & "Mbrs", dbInteger)
 
Note - you are breaking foundamental database normalization rules by placing "data" in the name of a field.

Joe Schwarz
Custom Software Developer
 
thanks so much Remou.... I tried that but I had left the ..,30)" at the end. I appreciate it!!!

Joe, thanks for the reply. I do realize this.

Thanks again!!!

Fred
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top