当我设置日期的默认值时,主键不会保存在表中 [英] The primary key wont save in the table when i set the default value of the date

查看:84
本文介绍了当我设置日期的默认值时,主键不会保存在表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有一个包含2个文本框的表单和一个包含发票详细信息的子表单。

第一个文本框是txtInvoice并且它绑定到发票表中的Invoice_number,它是一个自动编号。第二个文本框是txtDate,它绑定到Invoice表中的Invoice日期。

子窗体通过发票编号(txtInvoice)与主窗体相关。

问题是我将txtDate的默认值设置为sysdate(= date) ()),发票明细的每条记录都将保存在Invoice_detail表中,而不包含txtInvoice(没有发票编号!!)。

在表格Invoice中,记录将不会保存。

但是如果我没有把txtDate = date()

的默认值,那么所有记录都将在两个表中正确保存,并带有发票编号。

有没有人知道为什么?

Hi I have a form that contains 2 text boxes and a subform contain the Invoice details.
the 1st text box is txtInvoice and its bound to Invoice_number in the invoice table , it''s an auto-number. and the 2nd text box is the txtDate it''s bound to the Invoice date in the Invoice table.
the subform is related to the main form by the Invoice number (txtInvoice).
The problem is when i set the default value of the txtDate as the sysdate (=date()) , each record of the invoice detail will be saved in the Invoice_detail table without the txtInvoice (without the Invoice number!!).
And in the table Invoice the record will not be saved .
But if i don''t put the default value of the txtDate= date()
all the records will save correctly in both tables , with the Invoice number .
Did any one know why ??

推荐答案

显而易见的原因是没有在主表单中创建记录,因此没有记录已被保存到发票表中。
The obvious reason is that no record has been created in main form and thus no record has been saved into Invoice table.


但它是一个绑定的文本框,它必须自动保存!!
But it''s a bound text box and it must save automatically !!


它不会被保存直到您更改记录的任何字段。由于自动编号字段不可编辑且日期字段已显示,因此正确的值我想没有做出任何改变而且没有创建记录。
It won''t be saved until you make change to any field of a record. Since autonumber field is not editable and date field already "shows" right value I guess no changes are made and no record is being created.


这篇关于当我设置日期的默认值时,主键不会保存在表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆