Solved

Only = to part of the text

Posted on 1998-08-31
4
165 Views
Last Modified: 2010-04-30
Hi,  

What I am trying to do is that if a part of the text is equal to the string then run the procedure. Right no the text box has to equal = "PORT  1 MAT  123         POINT  5 FAIL ALM LVL D" .  I just want everyhting that has FAIL ALM LVL D to react to this regardless of what is in front of it.  The [text] = " *FAIL ALM LVL D"  does not work for me.  Can anyone help??

Private Sub Form_Current()
On Error GoTo Err_Form_Current
   
    If [Check28] = False Then                                                           'checks if the alarm seen button is checked
            If [Text7] = "PORT  1 MAT  123         POINT  5 FAIL ALM LVL D  " Then      'if the text value = an alarm then continue
             Dim Counter As Integer
                Do While Counter < 200                      ' Inner loop runs 200 times
                Counter = Counter + 1                       ' Increment Counter.
       
                 [lblAlarmNotification].Visible = True      ' sets the alarm notification text box to visible
                 [lblAlarmNotification].ForeColor = 255     ' changes color of box to red
                 DoCmd.Beep                                 ' computer speaker beeps
                 btn_timer_stop_Click                       ' runs the timer stop button and freezes the record.
                Loop
             
        Else
            [lblAlarmNotification].Visible = False          ' if the alarm doesn't exist the not visible
        End If
    Else
        End If
     
Exit_Form_Current:
    Exit Sub
Err_Form_Current:
    MsgBox Err.Description
    Resume Exit_Form_Current
End Sub
0
Comment
Question by:Nelmarcas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 2

Accepted Solution

by:
BergJC earned 20 total points
ID: 1432074
Try this:

Goodstring = "FAIL ALM LVL D"
For x = 1 To (Len(Text7) - (Len(Goodstring) - 1))
    If Mid$(Text7, x, Len(Goodstring)) = Goodstring Then
        'do code
    End If
Next
0
 
LVL 1

Expert Comment

by:CarlosJac
ID: 1432075
This aproach is  better

Goodstring = "FAIL ALM LVL D"
if right(Text7, Len(Goodstring)) = Goodstring Then
        'do code
End If

0
 
LVL 1

Expert Comment

by:lawnranger
ID: 1432076
That's a waste! How about simply...
     Goodstring = "FAIL ALM LVL D"
     If InStr(Text7.Text, Goodstring) then
         'do code
     endif

0
 

Author Comment

by:Nelmarcas
ID: 1432077
Hey they all work well, afterall  BerJC answered it first,  thanks for the great answers.


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question