# Miscellaneous > Database Programming >  SilentCmdText error With date validation

## alarabie

I have a table into which I insert records with a silent command. This was working fine until I decided to make a date field default to now() in the Access database. This date field previously add a validation rule that said that the date could not be in the future (<now()). The silent command worked fine with the validation rule, but adding the default of now(), causes the silent command to fail with an "invalid silent command error". Adding records in Access with the default and the validation rules works fine.

You can reproduce this by running this test procedure without making any changes to Nwind and then cause the error by adding a default date of now() in the orderdate field of the Orders table and a validation rule of <now().

The silent command will work with the default or the validation rule by themselves both not together. 

<body onLoad="self.focus()">
<script language="vb" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
Dim k3 As New Tornado.Z()
     With k3
      .dbUnit = 876
      .dbDSN=Application("nwind")
      .dbSilentCmdText="command=insert into orders (employeeid) values (4)"
      .ASPdbexecutecmd   
   End With
   Dim Mydb As New Tornado.Z()
   With Mydb
     .dbNavigationItem = "basic5"
     .dbbookmark ="test1;2" 

         .dbQP = "Unit=444| Mode=Grid|gdf=0,1,2,3,4,5,6,7| Skin=plain| DSN=nwind| TextHolder=Title=Basic Grid |SQL=SELECT * from orders "
     .ASPdbNET()
   End With
End Sub

</script>

----------


## Frank

Not clear about the description. State the exact procedures to reproduce the problem.

FK

----------


## alarabie

In the order table, change the order date field properties to default to "now()" and also add validation that the date cannot be in the future "<now()". The silent command will fail, then remove either one of these properties on the order field and the silent command will work again, the silent command works with either properties but not with both. Access has no problem with that.

----------


## Frank

silentcmd executes the "command" and that is it. it shoudl hav enothing to do with validation. Show the code that breaks.

FK

----------


## alarabie

the code that I included above will break nwind, all you have to do is put the defaul and the validation on the order date in the database.

----------


## Frank

there is no edit code anywhere in your example code? Furnish the exact code that breaks. The silentcmd is querying the "employees" table  and the other module is querying on "orders" table and you say they are related ?


FK

----------


## alarabie

Thats all there is to the code, the field properties are database properties set in the access table. Open Access and open the order table in design mode and change the properties on the order date field as described.

The code you have is all there is to the code, there are no validation done in the code. If you then try to run the silent command to create a new order table record you will get an invalid silent command error.

The problem I have is that the silent command does not work, if there is a default value and a validation rule specied in the Access table, it works with either one but not with both.

----------


## Frank

OH.. the validation is insdie the ACCESS an dnot in Tornado. In this case - execute the query in you ACCESS with the validation set and see whether it works without Tornado.

insert into orders (employeeid) values (4)"

Essentially Tornado just execute the SQL.''FK

----------


## John

Hi Andre,

This is so simple it's gonna kill you!

Your validation has to be <= now() not < now() 

If you put in a default of now() and then say it's only valid if it's < now() how can that work?

Change it to <= and you should be fine.

John

----------


## alarabie

Thanks, John you are correct, It's one of those brain farts that catches you once in a while.

----------


## Frank

glad to hear that problem is solved so it must be working...
I am still in the smoke? 

FK

----------

