PDA

View Full Version : next rows in continuous form doesn't update



sbbmaster09
06-10-2016, 10:57 AM
Hi, I have a continuous form. I am able to update the data if the continuous form has only one entry.

My problem is, when my query has multiple data, it only updates the 1st row of the continuous form. How can I update the other next entries?

Existing code below doesn't works. http://images.access-programmers.co.uk/forums/images/smilies/confused.gif


Set dbforms = CurrentDb
strSQL = "SELECT * FROM MainData WHERE [Enterprise ID] = '" & Me.txtAttUser.Value & "'"
Set rstforms = dbforms.OpenRecordset(strSQL, dbOpenDynaset)

rstforms.MoveFirst
Do Until rstforms.EOF

rstforms.Edit
rstforms("[Employment Status]").Value = Me.txtAttStat.Value
rstforms.Update

rstforms.MoveNext
Loop

rstforms.Close dbforms.Close

jonh
06-10-2016, 02:57 PM
that would update whatever record(s) has/have an id equal to txtattuser. id's are usually unique.

you shouldn't be using a loop to update records. use an update statement.


currentdb.execute "update sometable set myfield='whatever' where id='blah'"

SamT
06-10-2016, 03:47 PM
Please explain what a "Continuous Form" is. I have never heard the term. Is it an Access VBA Term?

jonh
06-10-2016, 03:50 PM
it displays multiple records vertically. like a table.

SamT
06-10-2016, 06:26 PM
Thanks, I don't Use Access.

sbbmaster09
06-13-2016, 04:25 AM
that would update whatever record(s) has/have an id equal to txtattuser. id's are usually unique.

you shouldn't be using a loop to update records. use an update statement.


currentdb.execute "update sometable set myfield='whatever' where id='blah'"

Hi Jonh,

I update the code to this, correct me if I'm wrong.. Getting an error: "Too few parameters. Expected 1."


strSQL = "UPDATE MainData SET [Employment Status] = Me.txtAttStat.value WHERE [Enterprise ID] = '" & Me.txtAttUser & "'"
dbforms.Execute (strSQL)

jonh
06-13-2016, 10:32 AM
You missed the quotes for attstat

"UPDATE MainData SET [Employment Status] ='" & Me.txtAttStat.value & "' WHERE [Enterprise ID] = '" & Me.txtAttUser & "'"