Užitočné (1) | Ardonaiel |
Option Compare Database Function FillFilteredRecords(F As Form, xTbl As String) Dim RS As DAO.Recordset, C As Control Dim FillFields As String, FillAllFields As Integer On Error GoTo xExit ' Goto the last record of the form recordset Set RS = F.RecordsetClone RS.MoveLast ' Exit if you cannot move to the last record (no records). If Err <> 0 Then GoTo xExit RS.MoveFirst For Each fld In RS.Fields If fld.Name <> "ID" Then 'autonumber xFldNames = xFldNames & IIf(xFldNames = "", "", ", ") & fld.Name End If Next fld Do Until RS.EOF xFldValue = "" For Each fld In RS.Fields If fld.Name <> "ID" Then 'autonumber If fld.Type = dbText Then x = "'" & Nz(fld.Value, "") & "'" ElseIf fld.Type = dbLongBinary Then 'treba riesit inak x = "''" Else x = Nz(fld.Value) End If xFldValue = xFldValue & IIf(xFldValue = "", "", ", ") & x End If Next fld xSQL = "INSERT INTO " & xTbl & " ( " & xFldNames & " ) " & " Values( " & xFldValue & ")" CurrentDb.Execute xSQL RS.MoveNext Loop RS.Close xExit: Set RS = Nothing End Function
Užitočné (1) | Ardonaiel |
MS Access: Vloženie dát z vnoreného formulára do tabuľky