Solved

Only = to part of the text

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now