run-time error '-247352567 (80020009)': You can't assign a value to this object

MGardner
MGardner used Ask the Experts™
on
When I open a form and use this code it works fine when there are no values asigned to the field on the form and I can then add the values to the form. However when I open the form and Me.txtRiskRating has a value assigned I get the error above.

So far I have ensured that the field properties in the table are set to Number for each of the fields involved.

Any ideas would why this is hapening would be appreciated
Private Function TxtRiskCalculations()

If cboSeverity.Value = "1" And Me.cboProbability.Value = "1" Then
    Me.txtRiskRating = "2"
    Call TxtRiskOutcome1
ElseIf cboSeverity.Value = "1" And Me.cboProbability.Value = "2" Then
    Me.txtRiskRating = "3"
    Call TxtRiskOutcome1
ElseIf cboSeverity.Value = "1" And Me.cboProbability.Value = "3" Then
    Me.txtRiskRating = "4"
    Call TxtRiskOutcome1
ElseIf cboSeverity.Value = "1" And Me.cboProbability.Value = "4" Then
    Me.txtRiskRating = "5"
    Call TxtRiskOutcome2
ElseIf cboSeverity.Value = "1" And Me.cboProbability.Value = "5" Then
    Me.txtRiskRating = "6"
    Call TxtRiskOutcome2
ElseIf cboSeverity.Value = "2" And Me.cboProbability.Value = "1" Then
    Me.txtRiskRating = "3"
    Call TxtRiskOutcome1

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I should have said that when the error message comes up and I go into de-bugging the line that highlights is  any of the relevant Me.txtRiskRating = "_"

 
Top Expert 2016

Commented:
<So far I have ensured that the field properties in the table are set to Number for each of the fields involved.>
Then, you should not be using  "1"  
for number type of data you don't need the " ", just use  1,2, or 3

Author

Commented:
Hi Capricorn1, thanks for the reply.
I did originally have the field type set to text which is why I hade the quotes around the numbers but forgot to change them, but have done so now. I am still getting the error though.
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Top Expert 2016

Commented:
what is the record source of the form? if it is a query, open the query and try to edit, see if will allow you to edit the records.

Author

Commented:
The record source is the table.
Top Expert 2016

Commented:
can you upload the db?

Author

Commented:
Hi I have slimmed the Db down to get it to upload
basically if you open mfrmRAGeneric and go to the risk matrix and enter a value in severity and probability and then close the form. when you reopen it. it then throws the error.
I assumed that on activate of the form that if it rechecked the calculations then it would just overwrite the value but it dosn't.

New-Microsoft-Access-Application.mdb
Top Expert 2016
Commented:
why do  you have to call a calculation in the activate event of the form?

Author

Commented:
No particular reason it was just that i thought that it would recalculate the form on opening in case of errors. Does that seem wrong then?
Top Expert 2016

Commented:
i don't see any relevance for doing so.

Author

Commented:
ok a silly addition then that should be taken out. I'll award the points for your patiance. Thanks
Top Expert 2016

Commented:
if you really want to do the testing, use the current event of the form.

Author

Commented:
Thanks for that Capricorn1 that does work though now I am wondering what the difference is in the on activate and on current that solves the problem as I recently remember reading somewhere (Can't remember where) that it is sometimes better to use on activate rather than on open or on current?
Top Expert 2016

Commented:
< that it is sometimes better to use on activate rather than on open or on current?>

that depends on what you are trying to do.
like this case, the codes are failing because the event you are using is too early to determine/set the values for the field.

Author

Commented:
Ok so I need to learn the difference in the methods/process timings that access uses in each type of opening. I can see I need to go away and read about it a little bit more closely.
Many thanks for the enlightenment.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial