if statement

7anthala

Registered User.
Local time
Today, 04:15
Joined
Apr 7, 2014
Messages
41
i have a problem with if statement, i have a combo box and a textfield, i wrote the following code:

Private Sub Combo107_Click()
If Me.Combo107 = "cxr" Then
Me.REP_DETAIL = "chest x-ray"

ElseIf Me.Combo107 = "ct" Then
Me.REP_DETAIL = "ct scan"
End If

End Sub

i compile the code, but i does not work
 
Try putting the code in the after_update event instead of the click event.
 
i tried but nothing happened in the form
i want a standard text to be inserted to the textfield according to what is chosen in combo box
 
Comparing strings can be tricky. Additionally, there are issues related to the number of items in your list and how the user enters that data. A listbox is a bit more rigid and would be less prone to error.

Try the construct below, just to get something working. Once it works, you can tweak it.

Code:
Private Sub Combo107_Click()
     trim(UCase(Me.REP_DETAIL)) = UCase("chest x-ray")
     trim(UCase(If Me.Combo107)) = UCase("ct") Then Me.REP_DETAIL = "ct scan"
End Sub
 

Users who are viewing this thread

Back
Top Bottom