B
Billp
Hi,
I have a form with a subform. The subform is linked parent to child. The
subform has a field that has a combo box.
From the combo there are two choices.
On the after update if the selcetion is equal too "INSERT ALL ITEMS - 32
LINES" the idea is to take the contents of a separate table line by line and
insert into the subform / subtable.
I Have the following code
If Me!cboProject_Notes.Column(0) = "INSERT ALL CHOICES - 32 LINES" Then
'do the input from the table tblProjectNotes_Default
Set db = CurrentDb
Set rst = db.OpenRecordset("tblProjectNotesDefault_1", dbOpenDynaset)
If rst.RecordCount <> 0 Then 'records exist
Do While Not rst.EOF
strOtherFields = ",Notes_Default"
strOtherFields = ",Notes_Default"
strsql = "INSERT INTO [tblsubProject_Notes]" _
& "(Works_Number" & strOtherFields & ")" _
& "SELECT '" & Forms!frmProject_Notes_1!Works_Number & "' As
NEWWorks_Number" _
& strOtherFields & " FROM tblProjectNotesDefault_1" _
& "WHERE Works_Number='" & Forms!frmProject_Notes_1!Works_Number
& "';"
DBEngine(0)(0).Execute strsql, dbFailOnError
rst.MoveNext
Loop
Else
'Do nothing
End If
rst.Close
Set rst = Nothing
Set db = Nothing
Else
Me!Project_Notes = Me!cboProject_Notes.Column(0)
End If
I get a Syntax error in FROM clause.
Other than that any suggestions, and where I have gone wrong or a better way
to do things is really really appreciated.
I have a form with a subform. The subform is linked parent to child. The
subform has a field that has a combo box.
From the combo there are two choices.
On the after update if the selcetion is equal too "INSERT ALL ITEMS - 32
LINES" the idea is to take the contents of a separate table line by line and
insert into the subform / subtable.
I Have the following code
If Me!cboProject_Notes.Column(0) = "INSERT ALL CHOICES - 32 LINES" Then
'do the input from the table tblProjectNotes_Default
Set db = CurrentDb
Set rst = db.OpenRecordset("tblProjectNotesDefault_1", dbOpenDynaset)
If rst.RecordCount <> 0 Then 'records exist
Do While Not rst.EOF
strOtherFields = ",Notes_Default"
strOtherFields = ",Notes_Default"
strsql = "INSERT INTO [tblsubProject_Notes]" _
& "(Works_Number" & strOtherFields & ")" _
& "SELECT '" & Forms!frmProject_Notes_1!Works_Number & "' As
NEWWorks_Number" _
& strOtherFields & " FROM tblProjectNotesDefault_1" _
& "WHERE Works_Number='" & Forms!frmProject_Notes_1!Works_Number
& "';"
DBEngine(0)(0).Execute strsql, dbFailOnError
rst.MoveNext
Loop
Else
'Do nothing
End If
rst.Close
Set rst = Nothing
Set db = Nothing
Else
Me!Project_Notes = Me!cboProject_Notes.Column(0)
End If
I get a Syntax error in FROM clause.
Other than that any suggestions, and where I have gone wrong or a better way
to do things is really really appreciated.