[Gllug] Visual Basic Help

Jackson, Harry HJackson at colt-telecom.com
Thu Jul 5 13:13:00 UTC 2001


Hi all

	Do not swear but I need help with VB. I am trying to iterate through
records on a form and some text manipulation is carried out for each record
as it runs through it. I can get the code to work if I scroll through the
records using the GUI but this is a bit silly because I am sure there is an
easier way to do it. The code is as follows. No smart comments at my
ineptitude with VB please ;-).

This works if I scroll through using the record counter in the access form.

Private Sub Form_Current()

Dim MyString, FirstWord, SecondWord, MyPos, MyPos2, MyPos3, MyPos4,
ThirdWord, FourthWord
Dim intX
intX = DCount("*", "REMEDY")


Forms!REMEDY!Short.SetFocus
FirstWord = Mid(Forms!REMEDY!Short, 1, 8) ' Returns "Mid".

    FirstWord = UCase(FirstWord)
    MyPos = InStr(1, Forms!REMEDY!WorkLog, "SPR ", 1)
    MyPos2 = InStr((1 + MyPos), Forms!REMEDY!WorkLog, "SPR ", 1)
    MyPos3 = InStr((1 + MyPos2), Forms!REMEDY!WorkLog, "SPR ", 1)
    MyPos4 = InStr((1 + MyPos3), Forms!REMEDY!WorkLog, "SPR ", 1)

If FirstWord Like "*SPR*" Then
        Forms!REMEDY!SPR = FirstWord
        
        Else: Forms!REMEDY!SPR = " "
        End If
    
    
    If MyPos = 0 Then
        Forms!REMEDY!SPR2 = ""
    Else:
                SecondWord = Mid(Forms!REMEDY!WorkLog, MyPos, 9)
                SecondWord = UCase(SecondWord)
                End If
                
    If MyPos2 = 0 Then
        Forms!REMEDY!SPR3 = ""
    Else:
                ThirdWord = Mid(Forms!REMEDY!WorkLog, MyPos2, 9)
                ThirdWord = UCase(ThirdWord)
                End If
    
    If MyPos3 = 0 Then
        Forms!REMEDY!SPR4 = ""
    Else:
                FourthWord = Mid(Forms!REMEDY!WorkLog, MyPos3, 9)
                FourthWord = UCase(FourthWord)
                End If
    
    
        Forms!REMEDY!SPR2 = SecondWord
        Forms!REMEDY!SPR3 = ThirdWord
        Forms!REMEDY!SPR4 = FourthWord
          
    
    
End Sub


Regards;
Harry Jackson.


     



**********************************************************************
COLT Telecommunications
Registered in England No. 2452736
Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ
Tel. 020 7390 3900

This message is subject to and does not create or vary any contractual
relationship between COLT Telecommunications, its subsidiaries or 
affiliates ("COLT") and you. Internet communications are not secure
and therefore COLT does not accept legal responsibility for the
contents of this message.  Any view or opinions expressed are those of
the author. The message is intended for the addressee only and its
contents and any attached files are strictly confidential. If you have
received it in error, please telephone the number above. Thank you.


**********************************************************************

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list