自动更新visual basic中的日期字段

时间:2016-01-08 17:04:48

标签: vb.net visual-studio-2008 ms-access-2007

所以我正在尝试为构建器构建一个应用程序,以便为客户提供新的估算值。

其中一项功能是,当他尝试创建新估算时,报价日期将自动填充估算值创建日期。

然后第二个日期字段自动填充为30天后,因此构建器可以知道引用何时到期。见下文:

enter image description here

如您所见,Access表中的日期字段未填写。

但是,当您使用日期选择器手动更改日期并将其设置为默认值以外的其他值时,它会起作用,请参见下文:

enter image description here

现在出现了。

以下是我用来自动设置日期选择器日期的代码:

Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' Adds today's date to the quote date as a defalut
        QuoteDateDateTimePicker.Value = Date.Today

        ' Creates automatic expiry date for quote in 30 days
        QuoteExpiryDateTimePicker.Value = Date.Today.AddDays(30D)

当我按下保存按钮时,我预计数据会被添加到表格中。 保存按钮:

' Save Quote
Private Sub btnSaveEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveEdit.Click
    ' This causes the Total button to be clicked so that when 
    ' users try to save the quote without pressing the "total" 
    ' button it doesn't save an empty quote.
    btnTotal_Click(sender, e)

    ' Save quote
    QuotesBindingSource.EndEdit()
    If TotalTextBox.Text = "" Then
        MsgBox("Please enter a some estimates")
    End If
    QuotesTableAdapter.Update(QuotesDataSet.quotes)
    End Sub

0 个答案:

没有答案