June7 thank you for your help.....I tried your suggestion but could not get it working,
Code:
strSQL = "SELECT IETM_ID FROM tbl_List_MME_SubTasks WHERE [MME_ID] = '1'"
Set rs1 = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs1.EOF Then Exit Sub
With rs1
Do Until .EOF
CurrentDb.Execute "INSERT INTO dbo_tbl_AVUM_Scored_Data(EI_ID, Event_Date, Event_No, Sys_Code, PHASE_ID, BOX_ID, IETM_ID) " & _
"VALUES(" & Me!EI_ID & ", #" & Me!Event_Date & "#, " & Me!Event_No & _
", " & Me!Sys_Code & ", " & Me!txboPhase_ID & ", " & Me!txboBox_ID & _
", " & rs1!IETM_ID & ")"
If Not .EOF Then .MoveNext
Loop
End With
I like your suggestion better but I think I will have to play around with it to get it working consistently......I can see the performance benefit to it. This is what I ended up with...I am kind of slow so it took me alittle bit to figure out what I was doing wrong......
Code:
Private Sub btnMMEXSMN_Click()
Dim db As DAO.Database
Dim rs1 As DAO.Recordset
Dim rsMME As DAO.Recordset
Dim strSQL As String
On Error GoTo ErrorHandler
strSQL = "SELECT IETM_ID FROM dbo_tbl_List_MME_SubTasks WHERE MME_ID = 1 "
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("dbo_tbl_AVUM_Scored_Data", dbOpenDynaset, dbSeeChanges)
Set rsMME = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
Do While Not rsMME.EOF
With rs1
.AddNew
For i = 0 To rsMME.Fields.Count - 1
!EI_ID = Forms!frm_Acft_Score!EI_ID
!Event_Date = Forms!frm_Acft_Score!Event_Date
!Event_No = Forms!frm_Acft_Score!Event_No
!Sys_Code = Forms!frm_Acft_Score!Sys_Code
!PHASE_ID = Forms!frm_Acft_Score!txboPhase_ID
!BOX_ID = Forms!frm_Acft_Score!txboBox_ID
!IETM_ID = rsMME(i).Value
Next i
.Update
End With
rsMME.MoveNext
Loop
ExitHandler:
rs1.Close
db.Close
Set rs1 = Nothing
Set db = Nothing
Exit Sub
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
Exit Sub
End Sub
How would I go about using this code for several different buttons on my page, instead of copying this code for every button and changing this Where clause....
Code:
strSQL = "SELECT IETM_ID FROM dbo_tbl_List_MME_SubTasks WHERE MME_ID = 1 "
I understand that I would have to make this a function and then make the WHERE MME_ID = & '', & "a variable" ....but any suggestions what to use.... maybe a button name or something like a IF..Then statement with the different choices...IE:
If a = btnName1 Then MME_ID = 1
If a = btnName2 Then MME_ID = 2
Am I headed in a logical direction?
Thanks again for all the help......