|
Dim mId As String
mId = InputBox("请输入发票号", "提示")
If mId = "" Then Exit Sub
If Nz(DLookup("InvoiceId", "tbTBuyInvoice", "InvoiceId='" & mId & "'"), "") = mId Then
MsgBox "此发票号已经存在,请重新输入!", vbExclamation, "提示"
Exit Sub
End If
'新建发票
'====================
Dim StrSql As String '不清楚你的字段类型,'UserName'为文本, #BuildDate#为日期
StrSql = "insert into tbTBuyInvoice(InvoiceId,BuildDate,BuildMan) "
StrSql = StrSql & " select '" & mId & "', '" & BuildDate & "', '" & DLookup("EmployeeId", "tbEmployee", "UserName='" & mUserName & "'") & "'"
CurrentProject.Connection.Execute (StrSql)
exit sub'加个断点=====================
你先用上面的代码试验一下看能否写入表头,BuildDate的变量是从哪里来的,应该没问题吧 |
|