I've been trying to create a Subroutine in VBA for my Access application:
Public Sub addProduct(ByRef Product As Product, AsFoo As Integer, Optional Mutual As Boolean = True)
Products.Add (Product)
If (Mutual) Then
Select Case AsFoo
Case 0
Product.setProjectmanager = Me
Case 1
Product.setVIP1 = Me
Case 2
Product.setVIP2 = Me
Case 11
Product.setVIP1A = Me
Case 22
Product.setVIP2A = Me
End Select
End If
End Sub
That one should just add the given Product to a Collection of Products and set the reference to the User reference, if Mutual is true.
That one should work... the problem is that I don't know how to call that my current try is:
User.addProduct(Product, 0, True)
But the IDE wants to have a = at the end so I thought that would work:
User.addProduct(Product, 0, True) = Product
But that causes a Compile Error:
Expected function or Variable
Try calling that line with:
User.addProduct Product, 0, True
or
Call User.addProduct(Product, 0, True)
Removing the ()
or using the Call
keyword should work for you.