Runtime Error 91, is the error I get.
This is the base code I have written to open a recordset:
**Begin base code**
Strsql = "SELECT bomts.*, Rotors.PartNumber, Rotors.Price, Rotors.Price2 FROM BOMTS LEFT JOIN Rotors ON BOMTS.Component = Rotors.PartNumber WHERE(isnull(BOMTS.[Level])) OR (((BOMTS.[Comp Proc Type])='F')) order by bomts.rcdcount"
Set rstsrc = db.OpenRecordset(Strsql)
rstsrc.MoveLast 'used to pull in full recordset
rstsrc.MoveFirst 'used to position to first record in recordset
Call UpdateHTS()
**End relevant base code**
I want to update records with a null field, so I created a public sub, and am calling this sub in my main routine above:
Public Sub UpdateHTS()
Strsql = "UPDATE BOMTS SET BOMTS.[Parent HTS] = '" & 999999999 & "' WHERE isnull(BOMTS.[Parent HTS]);" 'remove null HTS codes
Debug.Print Strsql
DoCmd.SetWarnings False 'Turn off warnings so records write without msg box
rstsrc.AddNew 'Prep for writing record
DoCmd.RunSQL Strsql 'SQL to append to table
DoCmd.SetWarnings True 'Turn warnings back on
I get the runtime 91 error when rstsrc.AddNew executes.
FYI, all of the code worked until I wanted to remove the null condition in the field BOMTS.[Parent HTS]
Do I need to declare a different SQL string and not use Strsql? Maybe Strsql1?
I need help on this please and thanks in advance.
This is the base code I have written to open a recordset:
**Begin base code**
Strsql = "SELECT bomts.*, Rotors.PartNumber, Rotors.Price, Rotors.Price2 FROM BOMTS LEFT JOIN Rotors ON BOMTS.Component = Rotors.PartNumber WHERE(isnull(BOMTS.[Level])) OR (((BOMTS.[Comp Proc Type])='F')) order by bomts.rcdcount"
Set rstsrc = db.OpenRecordset(Strsql)
rstsrc.MoveLast 'used to pull in full recordset
rstsrc.MoveFirst 'used to position to first record in recordset
Call UpdateHTS()
**End relevant base code**
I want to update records with a null field, so I created a public sub, and am calling this sub in my main routine above:
Public Sub UpdateHTS()
Strsql = "UPDATE BOMTS SET BOMTS.[Parent HTS] = '" & 999999999 & "' WHERE isnull(BOMTS.[Parent HTS]);" 'remove null HTS codes
Debug.Print Strsql
DoCmd.SetWarnings False 'Turn off warnings so records write without msg box
rstsrc.AddNew 'Prep for writing record
DoCmd.RunSQL Strsql 'SQL to append to table
DoCmd.SetWarnings True 'Turn warnings back on
I get the runtime 91 error when rstsrc.AddNew executes.
FYI, all of the code worked until I wanted to remove the null condition in the field BOMTS.[Parent HTS]
Do I need to declare a different SQL string and not use Strsql? Maybe Strsql1?
I need help on this please and thanks in advance.