[Gllug] Visual Basic Help

Wulf Forrester-Barker wulf.f-b at uhl.nhs.uk
Thu Jul 5 14:26:52 UTC 2001


Ah... that looks like Visual Basic for Applications (sticking programming behind an Access form)... I'm afraid I can't give specific help, but it looks like you need to throw in some kind of 'while not at end of recordset, advance to next record and repeat' loop. I used to find the Access VBA help files quite useful... I'd sit and stare at them for long periods and by a slow process of osmosis understanding would gradually form in my head (well, slow osmosis and lots of trial and error.... you're not working on live data are you?).

Wulf

>>> HJackson at colt-telecom.com 05/07/2001 2:13:00 pm >>>
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



wulf.f-b at uhl.nhs.uk

**********************************************************************
DISCLAIMER:

Any opinions expressed in this email are those of the individual and
not necessarily the Trust. This email and any files transmitted with
it are confidential and intended solely for the use of the individual
or entity to whom they are addressed. Any unauthorised disclosure of
the information contained in this e-mail is strictly prohibited.

The contents of this email may contain software viruses which could
damage your own computer system. Whilst we have taken every
reasonable precaution to minimise this risk, we cannot accept liability
for any damage which you sustain as a result of software viruses.
You should therefore carry out your own virus checks before opening
the attachment.

If you have received this email in error please notify the sender or
postmaster at uhl.nhs.uk. Please then delete this email.

University Hospital Lewisham
Tel: 020 8333 3000
Web: www.uhl.ac.uk
**********************************************************************

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




More information about the GLLUG mailing list