Results 1 to 4 of 4

Thread: [RESOLVED] Code Error

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Resolved [RESOLVED] Code Error

    I was wondering if anyone could help me with an error I'm getting when trying to call a sub that takes multiple parameters. I keep getting a "Expected: = " error, however the sub does not return a value (therefore not a function) was wondering how to get this fixed. Any help is greatly appreciated.

    VB Code:
    1. 'CHECKZEROOH()*****************************************************************
    2. Private Function checkZeroOH(PICKSL As String, PROD As Long, DESC As String) As Boolean
    3.     Dim sql As String
    4.    
    5.     Set otherConnection = New ADODB.connection
    6.     otherConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    7.         "Data Source= G:\Finance\Inventory Control\CycleCount\DB\Z028.mdb"
    8.     otherConnection.Open
    9.     Set otherRecordset = New ADODB.recordSet
    10.    
    11.     sql = "SELECT [OH] FROM [Untitled] WHERE [PICKSL]='" & PICKSL & "' and [PROD]=" & PROD & " and [DESC]='" & DESC & "'"
    12.    
    13.     otherRecordset.Open sql, otherConnection, adOpenKeyset, adLockPessimistic, adCmdText
    14.    
    15.     If (sql = "0" Or sql = "") Then
    16.         'The PICK SLOT is zero
    17.         checkZeroOH = True
    18.         Exit Function
    19.     End If
    20.     checkZeroOH = False
    21.    
    22. End Function
    23. 'ENDOF*CHECKZEROOH()***********************************************************
    24.  
    25. 'ADDZEROOH()*******************************************************************
    26. Private Sub addZeroOH(PICKSL As String, PROD As Long, DESC As String, MANUID As String, HITI As String, OH As Integer)
    27.     Dim sql As String
    28.    
    29.     Set newConnection = New ADODB.connection
    30.     newConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    31.         "Data Source= G:\Finance\Inventory Control\CycleCount\DB\CycleCount.mdb"
    32.     newConnection.Open
    33.     Set newRecordSet = New ADODB.recordSet
    34.    
    35.     sql = "Insert into [MAIN] (PICKSL,SLOT,RES,PROD,[DESC],PACK," & _
    36.         "[MANU ID],HITIX, [PALLET ID],[PALLET QTY],DFP) VALUES ('" & _
    37.         PICKSL & "','',''," & PROD & ",'" & DESC & "','','" & MANUID & "','" & HITI & _
    38.         "',''," & OH & ",''"
    39. MsgBox (sql)
    40.     newConnection.Execute sql
    41.    
    42.     sql = "Insert into [ALTER] (USERNAME,DATEOFCHANGE," & _
    43.         "TYPEOFCHANGE,PICKSL,SLOT,RES,PROD,[DESC],PACK," & _
    44.         "[MANU ID],HITIX, [PALLET ID],[PALLET QTY],DFP) VALUES (" & _
    45.         "'p6b0438',#" & Now() & "#," & "'ZERO OH ADDED','" & _
    46.         PICKSL & "','',''," & PROD & ",'" & DESC & "','','" & MANUID & "','" & HITI & _
    47.         "',''," & OH & ",''"
    48. MsgBox (sql)
    49.     newConnection.Execute sql
    50.    
    51.     newRecordSet.Close
    52.     newConnection.Close
    53.     Set newRecordSet = Nothing
    54.     Set newConnection = Nothing
    55. End Sub
    56. 'ENDOF*ADDZEROOH()*************************************************************
    57.  
    58. 'LOOPTHRUZEROOH()**************************************************************
    59. Private Sub loopThruZeroOH()
    60.     Set connection = New ADODB.connection
    61.     connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    62.         "Data Source= G:\Finance\Inventory Control\CycleCount\DB\Z028.mdb"
    63.     connection.Open
    64.     Set recordSet = New ADODB.recordSet
    65.     recordSet.Open "Untitled", connection, adOpenKeyset, adLockPessimistic, adCmdTable
    66.    
    67.     recordSet.MoveFirst
    68.     Do Until recordSet.EOF
    69.         If (checkZeroOH(recordSet.Fields("PICKSL"), recordSet.Fields("PROD"), _
    70.             recordSet.Fields("DESC")) = True) Then
    71. '////THE ERROR IS ON THE NEXT LINE ///////////////////////////////////            
    72.             addZeroOH(recordset.Fields("PICKSL"), _
    73.                       recordset.Fields("PROD"), _
    74.                       recordset.Fields("DESC"), _
    75.                       recordset.Fields("MANUID"), _
    76.                       recordset.Fields("HITI"), _
    77.                       recordset.Fields("OH"))
    78.            
    79.            
    80.             addZeroOH(recordSet.Fields("PICKSL"), recordSet.Fields("PROD"), _
    81.                 recordSet.Fields("DESC"), recordSet.Fields("MANUID"), _
    82.                 recordSet.Fields("HITI"), recordSet.Fields("OH"))
    83.         End If
    84.         recordSet.MoveNext
    85.     Loop
    86.  
    87. End Sub
    88. 'ENDOF*LOOPTHRUZEROOH()********************************************************

    Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Code Error

    When calling procedures use either

    Call addZeroOH(recordSet.Fields("PICKSL"),...)

    or don't specify Call and don't use the brackets

    addZeroOH recordSet.Fields("PICKSL"), ...'rest of parameters

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Re: Code Error

    I should have known that! Thanks!

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Code Error

    Now that we've helped you, you can help us by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer. Also if someone has been particularly helpful, or even particularly unhelpful, you have the ability to affect a their forum "reputation" by rating their post.

Posting Permissions

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



Click Here to Expand Forum to Full Width