Basic Select Case Statement not working?

Jason1971

Registered User.
Local time
Tomorrow, 10:14
Joined
Jan 19, 2009
Messages
46
(Newbie) Hi, I'm trying to get the "Stenosis Grade Code" field value to be updated to the value of "1" or "2" but it's not happening. Is the txt in green and red below correct?

Private Sub Form_AfterUpdate()

Select Case Me.[Stenosis Grade].Value
Case 1
Me.[Stenosis Grade].Value = "<50%"
Me.[Stenosis Grade Code].Value = 1
Case 2
Me.[Stenosis Grade].Value = ">50%"
Me.[Stenosis Grade Code].Value = 2
End Select
End Sub

Thanks,
Jason.
 
Hi Jason,

Firstly, in order to avoid confusion between Fields (in your table) and Controls (on your form) you should give your Controls a different name than your corresponding Fields (used as the Controls' "Control Source").

Once you have that sorted out, then fix your Select Case statement:
By the looks of it, [Stenosis Grade] is a String datatype, therefore the Cases you test for need to be Strings, i.e.,
Code:
Select Case Me.txt_Stenosis_Grade
  Case "<50%"
    [Stenosis Grade Code] = 1
  Case ">50%"
etc.,
Of course, this is based on conjecture until point 1 gets sorted and we know what datatypes we're dealing with.

HTH,
John
 
Your code works Great!, thank you John.
 

Users who are viewing this thread

Back
Top Bottom