我非常擅长访问并正在处理数据库。我有一个表单(frmHomeowner),带有一个用于邮政编码的绑定多列组合框(cboZip)。组合框基于来自tblZipCity [zipid(PK),zipcode,city,state]的查询,一旦选择了邮政编码,城市和州文本框就会自动填充。 我试图通过打开frmCitiesZip来添加新记录,添加一个新的邮政编码添加到cboZip的Not In List事件列表的选项:
Private Sub cboZip_NotInList(NewData As String, Response As Integer)
Dim Result
Dim Msg As String
Dim CR As String
CR = Chr$(13)
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
' Ask the user if he or she wishes to add the new zip code.
Msg = "'" & NewData & "' is not in the list." & CR & CR
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
' If the user chose Yes, start the CityZip form in data entry
' mode as a dialog form, passing the new zip code in
' NewData to the OpenForm method's OpenArgs argument. The
' OpenArgs argument is used in the homeowner form's Form_Load event
' procedure.
DoCmd.OpenForm "frmCitiesZip", , , , acAdd, acDialog, NewData
End If
' Look for the zip code the user created in the zip code form.
Result = DLookup("[zipcode]", "frmCitiesZip", _
"[zipcode]='" & NewData & "'")
If IsNull(Result) Then
' If the zip code was not created, set the Response argument
' to suppress an error message and undo changes.
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
' If form's OpenArgs property has a value, assign the contents
' of OpenArgs to the zipcode field. OpenArgs will contain
' a zip code if this form is opened using the OpenForm
' method with an OpenArgs argument, as done in the homeowner
' form's cboZip_NotInList event procedure.
Me![zipcode] = Me.OpenArgs
End If
End Sub
但我似乎围绕这一行遇到了一个问题:
结果= DLookup(" [zipcode]"," frmCitiesZip",_ " [邮编] ='" &安培; NewData& "'&#34) 如果IsNull(结果)那么
当我输入当前不在列表中的邮政编码时,我会收到提示,询问我是否要添加到列表中,但在将其添加到frmCitiesZip并关闭表单后,我收到错误消息: 运行时错误'3078'表示访问无法找到输入表或qry'frmCitiesZip'。
frmCitiesZip基于qryCitiesZip。不确定我做错了什么。任何帮助,将不胜感激。谢谢!