MySql Access VB

时间:2015-08-03 20:50:23

标签: mysql vba ms-access access-vba

My application is
Microsoft Access front end
MySql back end
Code is in vb

我正在尝试修改一个包含几个下拉字段的表单[![在此处输入图像说明] [1]] [1]。在更新之前我需要它来要求 jobcustomerID 。现在,如果我首先添加一个地址,它会告诉我添加客户但是给我一个错误"无效使用null"

当前代码

    Private Sub Form_BeforeUpdate(Cancel As Integer)
       If IsNull(Me.JobCustomerID) Or Me.JobCustomerID = "" Then
            Call MsgBox("You must select a Customer from the list provided", vbExclamation, "REQUIRED ENTRY")
             Me.JobCustomerID.SetFocus
             Cancel = True
             Exit Sub
           End If
       End Sub

我确实有一个字段的图像,但缺乏所需的声誉

1 个答案:

答案 0 :(得分:0)

尝试将取消移到前面。

If IsNull(Me.JobCustomerID) Or Me.JobCustomerID = "" Then
    Cancel = True
    MsgBox "You must select a Customer from the list provided", vbExclamation, "REQUIRED ENTRY"
    Me.JobCustomerID.SetFocus
    Exit Sub
End If