ник: helena
Private Sub загрузитьДанныеВФорму()
Dim Рекордсет As ADODB.Recordset
Set cnn = New ADODB.Connection
Dim fld As ADODB.Field
Dim i As Integer
Dim ctl As Control
Dim frmCurr As Form_ФормаБаза
cnn.Open "file Name=" & CurrentProject.Path & "\соединениеБазаДляСвязи.udl"
Set Рекордсет = New ADODB.Recordset
Рекордсет.Open "select * from ФИО", cnn, adOpenKeyset, adLockBatchOptimistic
Set frmCurr = Form_ФормаБаза
frmCurr.SetFocus
If Рекордсет.RecordCount > 0 Then
For Each fld In Рекордсет.Fields
For Each ctl In frmCurr
If ctl.Name = fld.Name Then
frmCurr(ctl.Name).Value = fld.Value
End If
Next ctl
Next fld
End If
Set cnn = Nothing
End Sub
Private Sub сохранитьДанныеВИзФормыВРекордсет()
Dim Рекордсет As ADODB.Recordset
Dim Рекордсет1 As ADODB.Recordset
Set cnn = New ADODB.Connection
Dim fld As ADODB.Field
Dim i As Integer
Dim ctl As Control
Dim frmCurr As Form_ФормаБаза
Rem On Error Resume Next
cnn.Open "file Name=" & CurrentProject.Path & "\соединениеБазаДляСвязи.udl"
Set Рекордсет = New ADODB.Recordset
Рекордсет.CursorLocation = adUseClient
Рекордсет.Open "select * from ФИО", cnn, adOpenKeyset, adLockBatchOptimistic
MsgBox Рекордсет.Fields(0)
Set frmCurr = Form_ФормаБаза
MsgBox Рекордсет.Supports(adAddNew)
MsgBox Рекордсет.Supports(adUpdate)
frmCurr.SetFocus
If Рекордсет.RecordCount > 0 Then
For Each fld In Рекордсет.Fields
For Each ctl In frmCurr
If ctl.Name = fld.Name And ctl.Name <> "Код" Then
Рекордсет(ctl.Name).Value = frmCurr(ctl.Name).Value
rem Рекордсет!имя = "новоеИмя"
Рекордсет.Update
End If
Next ctl
Next fld
End If
End Sub