Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.
Hi,
I'm struggling with DEFAULTVALUE again when producing tables with VBcode, not by hand in DesignView.
What i have is a NEW table that i'm using for AuditTrail with a field named TimeStamp that has (in DesignView) the
defaultvalue of Format(Now(), "dd\,mmm\,yyyy\,hh:nn:ss")
Monthly i need to email the tables from the application by using a simple transportable database which i attach to an email.
With a bit of code (the audit table part-of below) i build the database, tables and export the relevant data into the tables.
Set dbs = wspdef.CreateDatabase(New_
Set audit_tblDef = dbs.CreateTableDef("AuditT
With audit_tblDef
Set idx = .CreateIndex("AuditIndex")
With idx
.Fields.Append .CreateField("TransactionI
End With
.Indexes.Append idx
Set fld = .CreateField("TransactionI
fld.Attributes = fld.Attributes + dbAutoIncrField
.Fields.Append fld
* My problem is - I can't get what's in the brackets to be defaultvalue, it puts the date/time (i'd like to swear here!) whereas i want "Format()" etc.
Set fld = .CreateField("TimeStamp", dbText, 25)
fld.DefaultValue = (Format(Now(), "dd\,mmm\,yyyy\,hh:nn:ss")
.Fields.Append fld
**************************
.Fields.Append .CreateField("UserName", dbText, 50)
.Fields.Append .CreateField("WorkstationN
.Fields.Append .CreateField("UserInput", dbText, 50)
dbs.TableDefs.Append audit_tblDef
End With
I know before you say it that i can do the format() bit when passing data to the table at the .addnew stage in my AuditTrail Function.
BUT i've had problems setting up DEFAULTVALUE and FORMAT parts by VBcode before and given up and really i'd like to know how to do it.
Last time i was trying by code to make the tick-boxes appear in the fields with the Format part but failed.
At best i managed true/false yes/no but i couldn't produce that blank tickbox that appears in designview when you select "Yes/No"
Any help would be appreciated thanx.
AndyB.
Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.
Posted on 2003-08-12 at 04:36:55ID: 35590894
All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.