以下脚本在第5行给出了“预期语句结束”错误。我有其他类似的脚本可以正常运行,但没有第3行。我有没有项目ID的行,这就是为什么我把第2行放在那里。对不起,如果它很乱 - 我对此很新!
Private Sub Export_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
If GetCurrentColumnValue("IMA_ItemID") Is Nothing Or GetCurrentColumnValue("IMA_ItemID") IsDBNull Then
Me.Export.text = "" _
ElseIf GetCurrentColumnValue("IMA_ItemID") isnotnull AND GetCurrentColumnValue("IMA_CountryOfOrigin") = "USA" Then
Me.Export.text = "*** These commodities, technology, or software were exported from the United States in accordance with the Export Administration Regulations. Diversion contrary to United States law is prohibited."
Else
Me.Export.text = ""
End If
End Sub
在我放入第2行之前,它看起来像这样。但是,当itemid为null时,我在打印时遇到错误:
Private Sub Export_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
If GetCurrentColumnValue("IMA_CountryOfOrigin") = "USA" Then
Me.Export.text = "*** These commodities, technology, or software were exported from the United States in accordance with the Export Administration Regulations. Diversion contrary to United States law is prohibited."
Else
Me.Export.text = ""
End If
End Sub
由于
这是没有行号的代码。对不起 - 我认为这会让我更容易理解我的问题:谢谢你jmcilhinney - 我改变了我的isnotnull并不是什么都没有。
Private Sub Export_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
If GetCurrentColumnValue("IMA_ItemID") Is Nothing Or GetCurrentColumnValue("IMA_ItemID") IsDBNull Then
Me.Export.text = "" _
elseIf GetCurrentColumnValue("IMA_ItemID") IsNot Nothing _
AND GetCurrentColumnValue("IMA_CountryOfOrigin") = "USA" _
Then
Me.Export.text = "*** These commodities, technology, or software were exported from the United States in accordance with the Export Administration Regulations. Diversion contrary to United States law is prohibited."
Else
Me.Export.text = ""
End If
End Sub
答案 0 :(得分:0)
Private Sub Export_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
If GetCurrentColumnValue("IMA_ItemID") <> DBNull.Value AndAlso
GetCurrentColumnValue("IMA_CountryOfOrigin").ToString = "USA" Then
Me.Export.text = "*** These commodities, technology, or software were exported from the United States in accordance with the Export Administration Regulations. Diversion contrary to United States law is prohibited."
Else
Me.Export.text = ""
End If
End Sub
DbNull
的类型与Nothing
不同。您可以使用
If dataRow.IsNull("IMA_ItemID")
或
If dataRow("IMA_ItemID") = DBNull.Value