I am trying to code a SAVE button which will automatically change numerous rows of data within a table. I have created the appropriate query and checked it works when the form is open. However the coding doesn't work. I am not very good using the whole rst! syntax. I have attempted to get the code right and checked online for similar solutions however i have come up blank. The is as follows;
This code has been taken from the made up query which filters all the relevant information i require. Basically i would like the button to update all the fields within this query. The form itself is a single form. So the data changed would need changing to all rows of data within the query or rst.
I receive an error stating "Too few parameters Expected 3" however i have made sure all the details that could possibly be changed are on the form. I have still never managed to have a successful attempt at this sort of code so any advice would be much appreciated! Thanks
Code:
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT MaterialID, RangeID, ColourID, CarcussColourID, FasciaID, FasciaMaterialID, FasciaFinishID, SuppNo, PONo FROM ordlin WHERE (((ordlin.OrderNo)=[Forms]![frmSOLineDetails]![OrderNo]) AND ((ordlin.SuppNo)=[forms]![frmSOLineDetails]![SuppNo]) AND ((ordlin.ItemNo)=[forms]![frmSOLineDetails]![ItemNo])) OR (((ordlin.OrderNo)=[Forms]![frmSOLineDetails]![OrderNo]) AND ((ordlin.SuppNo)=[forms]![frmSOLineDetails]![SuppNo]) AND ((ordlin.ItemNoSub)=[forms]![frmSOLineDetails]![ItemNo])) OR (((ordlin.OrderNo)=[Forms]![frmSOLineDetails]![OrderNo]) AND ((ordlin.SuppNo)=[forms]![frmSOLineDetails]![SuppNo]) AND ((ordlin.ItemNoCmp)=[forms]![frmSOLineDetails]![ItemNo]))")
DoCmd.SetWarnings False
With rst
.Fields!MaterialID = cboMaterialDesc
.Fields!RangeID = cboRangeDesc
.Fields!ColourID = cboColourDesc
.Fields!CarcussColourID = cboCarcussColourDesc
.Fields!FasciaID = cboFasciaDesc
.Fields!FasciaMaterialID = cboFasciaMatDesc
.Fields!FasciaFinishID = cboFasciaFinDesc
.Fields!SuppNo = SuppNo
.Fields!PONo = PONo
.Update
End With
rst.Close
Set rst = Nothing
DoCmd.SetWarnings True
Code:
Set rst = db.OpenRecordset("SELECT MaterialID, RangeID, ColourID, CarcussColourID, FasciaID, FasciaMaterialID, FasciaFinishID, SuppNo, PONo FROM ordlin WHERE (((ordlin.OrderNo)=[Forms]![frmSOLineDetails]![OrderNo]) AND ((ordlin.SuppNo)=[forms]![frmSOLineDetails]![SuppNo]) AND ((ordlin.ItemNo)=[forms]![frmSOLineDetails]![ItemNo])) OR (((ordlin.OrderNo)=[Forms]![frmSOLineDetails]![OrderNo]) AND ((ordlin.SuppNo)=[forms]![frmSOLineDetails]![SuppNo]) AND ((ordlin.ItemNoSub)=[forms]![frmSOLineDetails]![ItemNo])) OR (((ordlin.OrderNo)=[Forms]![frmSOLineDetails]![OrderNo]) AND ((ordlin.SuppNo)=[forms]![frmSOLineDetails]![SuppNo]) AND ((ordlin.ItemNoCmp)=[forms]![frmSOLineDetails]![ItemNo]))")
I receive an error stating "Too few parameters Expected 3" however i have made sure all the details that could possibly be changed are on the form. I have still never managed to have a successful attempt at this sort of code so any advice would be much appreciated! Thanks
Comment