[Gllug] Visual Basic Help

Paul Brazier pbrazier at cosmos-uk.co.uk
Thu Jul 5 15:00:00 UTC 2001


You could create a RecordSet object based on the data (you might also
know this as a cursor) and then step through each row "While Not .EOF"
using methods like .MoveNext and update each row. Just do a help search
for the RecordSet object and this will give an outline.

However, it sounds like you might be better off using a query.
Cursors/RecordSets aren't very efficient and a SQL update query would
probably be several orders of magnitude faster.

-----Original Message-----
From: HJackson at colt-telecom.com 
Sent: 05 July 2001 14:13
To: colt-telecom.com.HJackson; linux.co.uk;.gllug
Subject: [Gllug] Visual Basic Help


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



**********************************************************************
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. If you have received this email in error please notify
the originator.

This footnote also confirms that this email message has been checked
for the presence of computer viruses.

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

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




More information about the GLLUG mailing list