Consulting

Results 1 to 6 of 6

Thread: What does this section of code do

  1. #1
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,217
    Location

    What does this section of code do

    I have been reviewing some old code within the forum and came across this;

    For index = 1 To intI 
        .Edit
        ![Flow] = str
        .Update
        .MoveNext
    Next
    What does this line represent "![Flow] = Str"?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,770
    Location
    I know nothing about VBA and Access, but

    https://www.msaccesstips.com/2016/07...sage-with.html

    Dots and Exclamation Symbols.

    General Usages of the dot (.) and exclamation symbol (!) in object references.

    • A dot (.) - after an object name to access its methods or properties.
    • The exclamation mark (!) - after an object name, refers to the sub-object or control of the Top-level Object.
    but I didn't even understand the examples in the link
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,217
    Location
    Okay here's the full code as presented

    Option Compare Database
    
    Function een_tabel()
        Dim db As dao.Database
        Dim opentbl As dao.Recordset
        Dim intI As Integer, index As Integer ', teller As Long
        Dim dummy As String, dummynext As String, str As String
        On Error GoTo ErrorHandler
        Set db = CurrentDb
        Set opentbl = db.OpenRecordset("Test_old", dbOpenDynaset)
        If opentbl.EOF Then Exit Function
        'teller = 0
        With opentbl
            Do Until .EOF
                intI = 1
                str = ""
                dummy = ![ORDERID]
                str = ![Groep_Machines]
                .MoveNext
                If .EOF Then
                    dummynext = 1
                Else
                    dummynext = ![ORDERID]
                End If
                Do Until (dummy <> dummynext)
                    intI = intI + 1
                    str = str & "_" & ![Groep_Machines]
                    dummy = ![ORDERID]
                    .MoveNext
                    If .EOF Then
                        dummynext = 1
                    Else
                        dummynext = ![ORDERID]
                    End If
                    'dummynext = ![ORDERID]
                Loop
                For index = 1 To intI
                    .MovePrevious
                Next
                For index = 1 To intI
                    .Edit
                    ![Flow] = str
                    .Update
                    .MoveNext
                Next
                'teller = teller + 1
                'If teller = 320000 Then
                    'MsgBox "stop"
                'End If
            Loop
        End With
        opentbl.Close
        Set opentbl = Nothing
        Set db = Nothing
        Exit Function
        ErrorHandler:
        MsgBox "Fout doorgeven aan Danny" & vbCrLf & vbCrLf & "Error Number: " & _
        Err.Number & vbCrLf & "Error Source:" & Error.Source & vbCrLf & "Error Description: " & _
        Err.Description, vbCritical, "FOUT!"
        Exit Function 
    End Function
    The "![ ...something...]" is used more than once in the code. Lines 15, 16, 21, 25, 26, 31, 33,& 40 within the Function subset. Is it referring to a record within a table?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    you are working with recordset from a table (Test_old).
    "Flow" is a Text field on your table and each record is being assigned same string (str) to it.

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,217
    Location
    Thank you
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,770
    Location
    Quote Originally Posted by arnelgp View Post
    you are working with recordset from a table (Test_old).
    "Flow" is a Text field on your table and each record is being assigned same string (str) to it.
    I knew some smart Access person would have the answer
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •