J
johnb
I'm trying to loop thru all non PK or FK controls on a Form/Subform using the
sql statement below, but I get an error message "Number of query values and
destination field do not match".
I'd be grateful if some kind person point out the error of my ways!
TIA johnb
If Me.[SubForm1].Form.RecordsetClone.RecordCount > 0 Then
For Each ctl In Me.Controls
If ctl.Name = "Parts_ID" Or ctl.Name = "CPD_ID" Or ctl.ControlType =
acLabel Then
GoTo Flag1
End If
strSql = "INSERT INTO [tbl_Parts]( " & ctl.Name & ") " & _
"SELECT " & lngID & " As CPS_ID, " & ctl.Name & _
" FROM [tbl_parts] WHERE CPS_ID = " & Me.CPS_ID & ";"
Debug.Print strSql
DBEngine(0)(0).Execute strSql, dbFailOnError
Flag1:
Next ctl
Else
MsgBox "Main record duplicated, but there were no related
records."
End If
sql statement below, but I get an error message "Number of query values and
destination field do not match".
I'd be grateful if some kind person point out the error of my ways!
TIA johnb
If Me.[SubForm1].Form.RecordsetClone.RecordCount > 0 Then
For Each ctl In Me.Controls
If ctl.Name = "Parts_ID" Or ctl.Name = "CPD_ID" Or ctl.ControlType =
acLabel Then
GoTo Flag1
End If
strSql = "INSERT INTO [tbl_Parts]( " & ctl.Name & ") " & _
"SELECT " & lngID & " As CPS_ID, " & ctl.Name & _
" FROM [tbl_parts] WHERE CPS_ID = " & Me.CPS_ID & ";"
Debug.Print strSql
DBEngine(0)(0).Execute strSql, dbFailOnError
Flag1:
Next ctl
Else
MsgBox "Main record duplicated, but there were no related
records."
End If