VB 的DTpicker控件问题 5
我使用了个DTpicker控件,当我选择一个日期时间,然后点击添加按钮后,显示插入记录结果的日期不是我选择的日期时间,全部都是1905年的数值。我不能得到我通过控件选择日...
我使用了个 DTpicker控件,当我选择一个日期时间,然后点击添加按钮后,显示插入记录结果的日期不是我选择的日期时间,全部都是1905年的数值。我不能得到我通过控件选择日期 怎么回事?
代码如下:
Private Sub cmd_add_Click()
On Error Resume Next
Dim A As Boolean
Dim B As Integer
Dim strID As String
Dim FinanceClassID As String
Dim IncomeClassID As String
A = txt_money_setFocus()
If A = True Then
B = MsgBox("是否添加当新记录", vbYesNo + 32 + 256, "添加记录 ")
If B = vbYes Then
txtSQL = "select IncomeID from IncomeInfo"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.MoveLast
'获取新的的ID号
strID = mrc.Fields(0)
strID = processID(strID)
'通过资金类型名获取资金类型ID号
txtSQL = "select FinanceClassID from FinanceTypes where FinanceClassName='" & Combo3.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
FinanceClassID = mrc.Fields(0)
'通过收入类型名获取收入类型ID号
txtSQL = "select IncomeClassID from IncomeTypes where IncomeClassName='" & Combo2.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
IncomeClassID = mrc.Fields(0)
'插入新纪录
txtSQL = "insert into IncomeInfo values('" & strID & "'," & txt_money.Text & ",'" & FinanceClassID & "','" & IncomeClassID & " '," & Format(DTPicker1.Value, "yyyy-mm-dd") & ",'" & txt_detail.Text & "','" & txt_mome.Text & " ')"
Set mrc = ExecuteSQL(txtSQL, MsgText)
Call Db1
MsgBox "数据已经保存!", vbOKOnly + 64, "添加成功"
End If
Else
txt_money.SetFocus
End If
End Sub 展开
代码如下:
Private Sub cmd_add_Click()
On Error Resume Next
Dim A As Boolean
Dim B As Integer
Dim strID As String
Dim FinanceClassID As String
Dim IncomeClassID As String
A = txt_money_setFocus()
If A = True Then
B = MsgBox("是否添加当新记录", vbYesNo + 32 + 256, "添加记录 ")
If B = vbYes Then
txtSQL = "select IncomeID from IncomeInfo"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.MoveLast
'获取新的的ID号
strID = mrc.Fields(0)
strID = processID(strID)
'通过资金类型名获取资金类型ID号
txtSQL = "select FinanceClassID from FinanceTypes where FinanceClassName='" & Combo3.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
FinanceClassID = mrc.Fields(0)
'通过收入类型名获取收入类型ID号
txtSQL = "select IncomeClassID from IncomeTypes where IncomeClassName='" & Combo2.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
IncomeClassID = mrc.Fields(0)
'插入新纪录
txtSQL = "insert into IncomeInfo values('" & strID & "'," & txt_money.Text & ",'" & FinanceClassID & "','" & IncomeClassID & " '," & Format(DTPicker1.Value, "yyyy-mm-dd") & ",'" & txt_detail.Text & "','" & txt_mome.Text & " ')"
Set mrc = ExecuteSQL(txtSQL, MsgText)
Call Db1
MsgBox "数据已经保存!", vbOKOnly + 64, "添加成功"
End If
Else
txt_money.SetFocus
End If
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询