Hi- have been working on this for hours and cannot find the problem:
I'm trying to insert a text value into a table (from another table). I need to insert the text value, then I will insert other code to email a report (not shown here), and then loop to do the same thing until the end of recordset.
the values in the text field are ST33-1000, ST32-1015, ST32-1016, for example. When this is run, I receive a "enter parameter value" for the field ST32- which doesn't exist! ST32- is part of the actual record in the field!
Can anyone help!?!
I've only included the relevent code. I'm trying to run the code as-is to make sure it works properly:
Dim MyDB As Database
Dim MyRS As Recordset
Dim CurrentOrder As String
Dim stSql1 As String
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("qryordersemailstore")
MyRS.MoveFirst
Do Until MyRS.EOF
CurrentOrder = MyRS![ordernumb]
stSql1 = "INSERT INTO tblordnumbcurrentemail (ordnumb) SELECT tblordersemailstore.ordernumb1 FROM tblordersemailstore WHERE tblordersemailstore.ordernumb1 = " & CurrentOrder & ";"
DoCmd.RunSQL stSql1
MyRS.MoveNext
Loop
End Function
I'm trying to insert a text value into a table (from another table). I need to insert the text value, then I will insert other code to email a report (not shown here), and then loop to do the same thing until the end of recordset.
the values in the text field are ST33-1000, ST32-1015, ST32-1016, for example. When this is run, I receive a "enter parameter value" for the field ST32- which doesn't exist! ST32- is part of the actual record in the field!
Can anyone help!?!
I've only included the relevent code. I'm trying to run the code as-is to make sure it works properly:
Dim MyDB As Database
Dim MyRS As Recordset
Dim CurrentOrder As String
Dim stSql1 As String
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("qryordersemailstore")
MyRS.MoveFirst
Do Until MyRS.EOF
CurrentOrder = MyRS![ordernumb]
stSql1 = "INSERT INTO tblordnumbcurrentemail (ordnumb) SELECT tblordersemailstore.ordernumb1 FROM tblordersemailstore WHERE tblordersemailstore.ordernumb1 = " & CurrentOrder & ";"
DoCmd.RunSQL stSql1
MyRS.MoveNext
Loop
End Function