var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Update records based on value on from
I would like to update a field for all selected records (from a list box) based on the value on from
This is what I have; can you please help me with the rs.Edit lien? Or any other line that’s wrong.
Private Sub cmdupdate_Click()
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim ctl As Control
Dim varItem As Variant
On Error GoTo ErrorHandler
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblOrder", dbOpenDynaset, dbAppendOnly)
Set ctl = Me.List144
For Each varItem In ctl.ItemsSelected
rs!InternalID = ctl.ItemData(varItem)
rs!InvoiceNo = Me.txtInvoiceNumber
You'd have to move the recordset to each item inside the loop. Personally I'd ditch the recordset and run SQL:
db.Execute "UPDATE...WHERE KeyFieldName = " & ctl.ItemData(varItem)
Good idea of using db.Execute.
I never did it. Can you please tell me how sql should look starting from db.Execute?
I have spent lot of time to figure this out. I would very appropriate if you can put the full code the I need to have. I'm not good on this.
i have posted this few days go in diff group, but didnt get answer yet.
Along the lines of
CurrentDb.Execute "UPDATE tblOrder SET InvoiceNo = " & Me.txtInvoiceNumber & " WHERE InternalID = " & ctl.ItemData(varItem)
If my guess about your structure is correct.