create function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrijet
    New Member
    • Feb 2015
    • 64

    create function

    Good day everbody..

    Can anyone explain me, what was the function for the below code actually? Seems I'm still learning this Recordset, anyone can explain it for me what actually this code meaning?

    Code:
    Function Create(SupplierID As Long, EmployeeID As Long, OrderID As Long, PurchaseOrderID As Long) As Boolean
        Dim rsw As New RecordsetWrapper
        If rsw.OpenRecordset("Purchase Orders") Then
            With rsw.Recordset
                .AddNew
                ![Supplier ID] = SupplierID
                If EmployeeID > 0 Then
                    ![Created By] = EmployeeID
                    ![Creation Date] = Now()
                    ![Submitted By] = EmployeeID
                    ![Submitted Date] = Now()
                    ![Status ID] = Submitted_PurchaseOrder
                End If
                
                If OrderID > 0 Then
                    ![Notes] = InsertString(PurchaseGeneratedBasedOnOrder, CStr(OrderID))
                End If
                If rsw.Update Then
                    .Bookmark = .LastModified
                    PurchaseOrderID = ![Purchase Order ID]
                    Create = True
                End If
            End With
        End If
    End Function
  • Narender Sagar
    New Member
    • Jul 2011
    • 189

    #2
    This code is for creating or updating Purchase orders.

    Comment

    • mrijet
      New Member
      • Feb 2015
      • 64

      #3
      Thanks for replying...what does this codes mean..

      Code:
      [B]![Supplier ID][/B] = SupplierID
      What actually this symbol [!] for?

      Comment

      • Narender Sagar
        New Member
        • Jul 2011
        • 189

        #4
        This is the field in your form which is to be maintained, manually or logically. Like "Created By" will be filled by "EmployeeID "

        Comment

        • jforbes
          Recognized Expert Top Contributor
          • Aug 2014
          • 1107

          #5
          I think what is causing you confusion is the With Statement:
          Office Version
          Visual Basic Version

          In the Code Sample, they are using the With Statement on a RecordSet The RecordSet Object supports a couple different ways to reference a Field and ! is one of them:
          Code:
          To refer to a Recordset object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:
          Recordsets(0)
          Recordsets("name")
          Recordsets![name]

          Comment

          • mrijet
            New Member
            • Feb 2015
            • 64

            #6
            Thanks for replying....

            @jforbes means,
            Code:
            Recordsets("name")
            Recordsets![name]
            was same meanings code?

            Comment

            Working...