|
问题:
1、在主窗体录入信息后,点修改,所录信息无法更新到子窗体。
2、无法定位在修改的那条信息记录上,自动跳转到子窗体第一行。
Private Sub 修改_Click()
On Error GoTo Err_修改_Click
Dim i As Integer
Dim STemp As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
STemp = "Select * From 工程项目清单"
rs.Open STemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If IsNull(Me![id]) = True Then
MsgBox "请输入“id”,它不可以为空!", vbOKOnly, "输入“id”"
Me![id].SetFocus
ElseIf IsNull(Me![规划站名]) = True Then
MsgBox "请输入“规划站名”,它不可以为空!", vbOKOnly, "输入“规划站名”"
Me![规划站名].SetFocus
Else
rs.MoveFirst
For i = 1 To rs.RecordCount
If rs("id") = Me![工程项目清单子窗体]![id] Then
rs("规划站名") = Me![规划站名]
rs("经度") = Me![经度]
rs("纬度") = Me![纬度]
rs("建设方式") = Me![建设方式]
rs.Update
Me![工程项目清单子窗体].Requery
MsgBox "数据修改完成!", vbOKOnly, "修改完成"
Exit Sub
Else
rs.MoveNext
End If
Next i
End If
Set rs = Nothing
Exit_修改_Click:
Exit Sub
Err_修改_Click:
MsgBox Err.Description
Resume Exit_修改_Click
End Sub |
|