Solved

Only = to part of the text

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

707 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

13 Experts available now in Live!

Get 1:1 Help Now