保存记录变更 - 访问古董表格
问题描述:
请帮助!保存记录变更 - 访问古董表格
我已经创造了记录服务调用数据库的基础上,微软的模板之一(非常松散的,基于现在!)
我有一个“案例详细信息”的形式,这是从一个案例清单分裂形式打开。最初,这是打开一个过滤器的形式 - 我认为这意味着它实际上是加载整个记录集?
正如我假设(希望是正确的),这将是非常低效的数据库增长,我决定改变窗体打开和ADO记录集,使用SQL语句,只选择我想要的记录。
此代码如下,并打开窗体正确的记录,我可以更新字段。
Private Sub Form_Load()
On Error GoTo Form_Load_Err
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
If (IsNull(TempVars!currentid)) Then
Me.DataEntry = True
Else
'Use the ADO connection that Access uses
Set cn = CurrentProject.Connection
'Create an instance of the ADO Recordset class,
'and set its properties
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cn
.Source = "SELECT * FROM Cases WHERE ID = " & TempVars!currentid & ";"
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open
End With
'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rs
Set rs = Nothing
Set cn = Nothing
End If
Call IntializeCollections
Select Case (Me.Status)
Case 7, 8
Call EnableControls(mcolgrpAllFields, False)
End Select
Form_Load_Exit:
Exit Sub
Form_Load_Err:
MsgBox Error$
Resume Form_Load_Exit
End Sub
但是,这是问题所在。我该如何保存我的更改?我做了一些谷歌搜索,看着MS Access Form Bound to ADO Disconnected Recordset,但我仍然绝对难住。
有没有那么简单的“保存更新”命令?还是必须迭代每个字段,检查更改,然后保存这些更改?
有人可以请指出我在正确的方向吗?
在此先感谢
答
如果您需要更新一次一个记录尝试这种解决方案断开连接的记录:http://www.techrepublic.com/blog/how-do-i/how-do-i-pass-data-over-a-network-using-disconnected-recordsets/
我想,这是太简单了,我应该能找到它的网站的?难道没有人能将我指向正确的方向吗? – MikeH