Solved

Only = to part of the text

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

751 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