【发布时间】:2019-03-07 18:28:51
【问题描述】:
我一直有这个问题,似乎无法破解它。
我创建了一个单独的表单 (frmAdd) 来添加新记录。我想要它做的是当记录被创建到
- 将新记录添加到组合框 - 完成
- 让组合框显示到新记录 - 完成
- 将绑定表单移至新记录 - 不工作
该项目肯定在列表中,因为它显示了,但表单仍显示先前的记录。我使用了刷新和重新查询,但无济于事。 调用 After_Update 过程的原因是它不会自行运行(这可能是一个线索)
我在下面附上了代码和表单图像。您将在显示表单上看到一个记录显示在组合框中,但另一条记录显示在表单的其余部分。如果有任何帮助,我将不胜感激
Private Sub CboFind_AfterUpdate()
Dim rs As DAO.Recordset
If Not IsNull(Me.cboFind) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "[ClientID] = " & Me.cboFind
If rs.NoMatch Then
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
End Sub
Private Sub cmdNew_Click()
Dim ID As Integer
Dim strSQL As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
DoCmd.OpenForm "frmAdd", , , , , acDialog
If NewRec = True Then
Set db = CurrentDb
strSQL = "SELECT clientid,sname,fname,address,suburb from TBLCLIENTS where sname = '" & pubSName & "' AND fname = '" & pubFName & "' AND address = '" & pubAddr & "' AND suburb = '" & pubSuburb & "'"
Set rst = db.OpenRecordset(strSQL)
ID = rst!ClientID
Me.cboFind.SetFocus
Me.cboFind.Value = ID
Call CboFind_AfterUpdate
Me.cboFind.Requery
Set rst = Nothing
Set db = Nothing
End If
End Sub
【问题讨论】:
标签: ms-access