RecordSet Unable to Update?

  • Thread starter edisonl via AccessMonster.com
  • Start date
E

edisonl via AccessMonster.com

hi,

There is this 'funny' situation I don't quite understand.

1. I had a recordset open>> rd.Open table, conn, adOpenStatic,
adLockPessimistic
2. Data is able to be extract and perform arithmatic operations.
3. Programatically I tried>>
OnCancel_Button_Click()

TotalDays_Text = CDec (TotalDays_Text)
Taken_Text = CDec (Taken_Text)
Balance_Text = CDec(Balance_Text)

'Before Operation ************************
a= msgbox(rd!taken & rd!balance)

Taken_Text = Taken_Text - TotalDays_Text
Balance_Text = Balance_Text + TotalDays_Text

rd!taken = Taken_Text
rd!balance = Balance_Text

'After Operation **************************
a= msgbox(rd!taken & rd!balance)

' Am able to display here the value after operations, but back end table
there is no UPDATE ?
' In other form I am able to use similar methods to perform the arimithic
operations but this not on this form.
'I check with the form setting did set to allowededit = true too

Edison
 
A

April

Try changing the adOpenStatic to adOpenDynamic. With it opening as static I
don't think you can just update it, dynamic should allow you to use rs.Update
to update it.
 
E

edisonl via AccessMonster.com

Hi April,

Thanks for replying..

All right from what you had said.. here 's the funny part..

I had other form open(within the same program) as openstatic but its
updatable....But not this particular form..

Another perculiar scenerio, likewise you said previously I tried using
OpenDynamic But A2K do not allow to update & explicitly pop up error mesaage
saying Update operation not available.

Edison

Try changing the adOpenStatic to adOpenDynamic. With it opening as static I
don't think you can just update it, dynamic should allow you to use rs.Update
to update it.
[quoted text clipped - 29 lines]
 
E

edisonl via AccessMonster.com

Hi April,

Am afraid that something new crop up this time round.
I search for a particular record.

rd.open "MyForm", conn, adOpenDynamic, adLockOptimistic
rd.filter "Name='" & Name_Text & " '"

do until rd.EOF
If recordset=0 then
rd.addnew
 
A

AccessVandal via AccessMonster.com

You named your table "MyForm"? Some may confused it with a form not a table
or a query syntax.

"Name" is a reserved word in access. Try not to use it. If you can't change
it now, use a square bracket to enclose the reserved name object like "[Name]
='".

Do a compact and repair, see if the problem goes away.

Here's a helpful link to get you started.

http://www.accessmvp.com/Strive4Peace/Index.htm

http://home.att.net/~california.db/tips.html#aTip1
Hi April,

Am afraid that something new crop up this time round.
I search for a particular record.

rd.open "MyForm", conn, adOpenDynamic, adLockOptimistic
rd.filter "Name='" & Name_Text & " '"

do until rd.EOF
If recordset=0 then
rd.addnew
.
.

else
rd.update
.
.
end if

rd.movenext
loop

rd.close
conn.close
set rd = nothing
set conn = nothing

"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~
Error: Operation not allows in this context
"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~"~

Edison

X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
X X X X X X X X X X X X
Try changing the adOpenStatic to adOpenDynamic. With it opening as static I
don't think you can just update it, dynamic should allow you to use rs.Update
[quoted text clipped - 5 lines]
 
E

edisonl via AccessMonster.com

Hi Van,

Thanks for your reply, I use the name loosely to enable easy understanding
when explaining to you guys thats all.

Edison
You named your table "MyForm"? Some may confused it with a form not a table
or a query syntax.

"Name" is a reserved word in access. Try not to use it. If you can't change
it now, use a square bracket to enclose the reserved name object like "[Name]
='".

Do a compact and repair, see if the problem goes away.

Here's a helpful link to get you started.

http://www.accessmvp.com/Strive4Peace/Index.htm

http://home.att.net/~california.db/tips.html#aTip1
Hi April,
[quoted text clipped - 37 lines]
 
A

AccessVandal via AccessMonster.com

Than, I'm not sure your code statement is correct.

rd.filter "Name='" & Name_Text & " '"

Should it be

rd.filter = "Name='" & Name_Text & " '"

Which line the error point to?
 
S

Stefan Hoffmann

hi,

as I don't see the OP, this is just a guess...
Than, I'm not sure your code statement is correct.
rd.filter = "Name='" & Name_Text & " '"
.... remove the space before the closing single quote.



mfG
--> stefan <--
 
E

edisonl via AccessMonster.com

Hi Van/Stefan,

1. Yap no issue about the space and '=' sign

2. Though I refrained myself from any embarassement (though it still happen
at time, arghh..) by making those mistakes.

3. Anyway had managed to replace all the opening code with
*****************************************
strsql ="My Sql Statement"
currentdb.execute strsql
*****************************************
 
A

AccessVandal via AccessMonster.com

I’m aware of the space. I just leave it as it is, since we don’t have a clue
to his actual code or what he had intent to do with his pseudo code.
 
E

edisonl via AccessMonster.com

Hi Van & Stefan:

Its me again .

Just some info sharing... After 1 big wild goose chase I finally realised, I
need to
do another line of code thats all >>

rd.UpdateBatch adAffectCurrent

to 'complete' the table process, then Access allows me to

rd.close, set rd=nothing...

Like to thank both for the effort in guiding me.. ;p
Cheers



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top