quick question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how comes that when I click on the button Bttn01 an error message comes up on
my screen which says
"Object doesn't support this property or method (Error 438)"

the text of the corresponding procedure is the following

Private Sub Bttn01_Click()

Dim Result As Integer
Dim Tmp As Long

Result = 0

If Education = 4 Or Education = 5 Then Result = Result + 5

Score = Result

End Sub

Education and Score are the names of two fields in the active form.

Also, what is the way of updating the value of the field Score after a click
on button Bttn01 has been done?
 
438 is one of the vba error codes IIRC...

Try using the syntax which follows to refer to controls
(fields) on your form.

Me!Education instead of just Education
Me!Score instead of just Score

There are other ways to refer to controls on a form e.g.

The long explicit version for Education would be
Forms!FormName!Education

Lookup Controls Collection in the Help for more info..

I'd rewrite your code as follows:
Private Sub Bttn01_Click()

Dim Result As Integer
Result = 0

If Me!Education = 4 Or Me!Education = 5 Then
Result = Result + 5
EndIf

Me!Score = Result

End Sub

Question - Why are you setting result to 0 then setting it
to 5 then setting score = result? Any value you are feeding
in for the variable Result from somewhere else will be
negated by the Dim statement and the Result = 0 set.
Why not just do a Me!Score = 5 inside the If Then?

--
Nick Coe (UK)
http://www.alphacos.co.uk/ AccHelp + pAnimal
http://www.pjandcoe.co.uk/ Online Store
http://www.mrcomputersltd.com/ Repairs Upgrades

In Jimmy Ionic typed:
 
Back
Top