lynnton
asked on
DB error message
Hi,
error message: operation must be an updateable query. (ms access)
pointing at ---> Call cnForecast.Execute(RSforec ast.Fields ("command" ).Value)
rsforcast.Fields("command" ).value contains...
UPDATE forecastsched SET Relate = Iif(IsNull((SELECT MAX(Relate) FROM forecastsched)), 1, (SELECT MAX(Relate) FROM forecastsched) + 1) WHERE forecastID IN (49083, 49229);
__________________________ __________ __________ ____code
SQL="select...."
RSforecast.Open SQL, cnForecast, adOpenForwardOnly, adLockBatchOptimistic
Set RSforecast.ActiveConnectio n = Nothing
Do While Not RSforecast.EOF
Call cnForecast.Execute(RSforec ast.Fields ("command" ).Value)
RSforecast.MoveNext
DoEvents
Loop
Set RSforecast = Nothing
how to make this work?
Thanks,
Lynnton
error message: operation must be an updateable query. (ms access)
pointing at ---> Call cnForecast.Execute(RSforec
rsforcast.Fields("command"
UPDATE forecastsched SET Relate = Iif(IsNull((SELECT MAX(Relate) FROM forecastsched)), 1, (SELECT MAX(Relate) FROM forecastsched) + 1) WHERE forecastID IN (49083, 49229);
__________________________
SQL="select...."
RSforecast.Open SQL, cnForecast, adOpenForwardOnly, adLockBatchOptimistic
Set RSforecast.ActiveConnectio
Do While Not RSforecast.EOF
Call cnForecast.Execute(RSforec
RSforecast.MoveNext
DoEvents
Loop
Set RSforecast = Nothing
how to make this work?
Thanks,
Lynnton
make sure the mdb file is writeable (not read-only)
make sure you have the permission to change the mdb.
ASKER
hongjun,
It's an access db on the local machine, i'm able to add/delete records with no problems.
something with running Call cnForecast.Execute(RSforec ast.Fields ("command" ).Value)
Thanks,
Lynnton
It's an access db on the local machine, i'm able to add/delete records with no problems.
something with running Call cnForecast.Execute(RSforec
Thanks,
Lynnton
>>add/delete records
using codes? or manually?
using codes? or manually?
ASKER
hongjun,
Using sql query, when the form loads it "DELETE * from forecastsched"
hope this helps,
Thanks,
Lynnton
Using sql query, when the form loads it "DELETE * from forecastsched"
hope this helps,
Thanks,
Lynnton
I tried with a table on a my DB and I got the same error ...
If I replace the "Iif(IsNull((SELECT MAX(..." with a constant value all works fine ...
It seems as this subquery locks the table so you can't update it
Can't you do this operation in two steps? First you get the result for "Iif(IsNull((SELECT MAX(..." and then you update the table
If I replace the "Iif(IsNull((SELECT MAX(..." with a constant value all works fine ...
It seems as this subquery locks the table so you can't update it
Can't you do this operation in two steps? First you get the result for "Iif(IsNull((SELECT MAX(..." and then you update the table
ASKER
mmusante,
What do you mean?
Please write the code.
Thanks,
Lynnton
What do you mean?
Please write the code.
Thanks,
Lynnton
Hi Lynnton
Me again. One thing to try. Before you open the connection, try:
cnForecast.Mode = adModeReadWrite
Me again. One thing to try. Before you open the connection, try:
cnForecast.Mode = adModeReadWrite
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
IIf always evaluates both truepart and falsepart, even though it returns only one of them. Because of this, you should watch for undesirable side effects. For example, if evaluating falsepart results in a division by zero error, an error occurs even if expr is True.
ASKER
EDDYKT,
I see, what do you recommend? I've heard of NZ ?
how do we go about this?
Thanks,
Lynnton
I see, what do you recommend? I've heard of NZ ?
how do we go about this?
Thanks,
Lynnton
do
if
else
end if
instead of iif
if
else
end if
instead of iif
ASKER
EDDYKT,
Gotcha, do you know NZ and how to use it?
Thanks,
Lynnton
Gotcha, do you know NZ and how to use it?
Thanks,
Lynnton
No idea what is NZ is
?->
?->
<code snip>
RSforecast.Open SQL, cnForecast, adOpenForwardOnly, adLockBatchOptimistic
</code snip>
you opened your recordset as openforwardonly, change it to adOpenDynamic and your lock to adLockPessimistic
since openforwardonly sets your recordset to be read only.
HTH!!!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try using Access DMax function change your query to:
UPDATE forecastsched SET Relate = Nz(Dmax("Relate","forecast sched","") ,0)+1 WHERE forecastID IN (49083, 49229);
UPDATE forecastsched SET Relate = Nz(Dmax("Relate","forecast