ผมลอง convert จาก macro แล้ว เป็น vba คือ
Option Compare Database
'------------------------------------------------------------
' itemsalesMacro
'
'------------------------------------------------------------
Function itemsalesMacro()
On Error GoTo itemsalesMacro_Err
With CodeContextObject
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.Echo False, ""
DoCmd.OpenTable "itemtempTable", acViewNormal, acEdit
DoCmd.GoToRecord acTable, "itemtempTable", acFirst
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste
DoCmd.Close acTable, "itemtempTable"
DoCmd.Echo True, ""
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.Echo False, ""
DoCmd.OpenTable "itemtempTable", acViewNormal, acEdit
DoCmd.GoToRecord acTable, "itemtempTable", acFirst
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste
DoCmd.Close acTable, "itemtempTable"
DoCmd.Echo True, ""
If (Eval("[combo25] Is Null")) Then
.Combo25 = DLookup("[date]", "invoiceQuery10")
End If
If (Eval("[combo4] Is Null")) Then
.Combo4 = DLookup("[customerid]", "invoiceQuery10")
End If
If (Eval("[combo23] Is Null")) Then
.Combo23 = DLookup("[%vat]", "invoicetableremark", "[invoiceno]=combo27")
End If
'SendKeys "{F9}", True
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
DoCmd.Echo False, ""
DoCmd.OpenTable "itemtempTable", acViewNormal, acEdit
DoCmd.GoToRecord acTable, "itemtempTable", acFirst
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdPaste
DoCmd.Close acTable, "itemtempTable"
DoCmd.Echo True, ""
Exit Function
DoCmd.SetWarnings False
If (Eval("[combo25] Is Null")) Then
.Combo25 = Null
End If
If (Eval("[combo4] Is Null")) Then
.Combo4 = Null
End If
If (Eval("[combo23] Is Null")) Then
.Combo23 = Null
End If
End With
itemsalesMacro_Exit:
Exit Function
itemsalesMacro_Err:
MsgBox Error$
Resume itemsalesMacro_Exit
End Function
แล้วคราวนี้ จะให้ตรง properties นั้น ตรง after update นั้นมาเรียกใช้ จาก vba อย่างไงครับ ไปไม่ถูก