Solved

Only = to part of the text

Posted on 1998-08-31
4
155 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

820 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