Passing a Form in a Sub

J

Jamie

Hi

I have a Sub how takes a Form as parameter, I have to
call this Sub from a form to applicate the code so it's
take a Form as input I pass the name of the form: Me.form

But it's not working

This is my code:

The Sub:
========

Public Sub MaxSpecification(Frm As Form)
Dim intSpecifications As Variant
dim iSpecificationChoice As Variant

intSpecifications =
DCount"[SpecificationID]", "Tb_Specification", "[ItemID]
= " & 1

iSpecificationChoice = DCount
("[SpecificationID]", "Tb_SpecificationParLigneCommande",
"[LigneCommandeID] = " & 1

If intSpecifications = iSpecificationChoice Then
Frm .AllowAdditions = False
Else
Frm .AllowAdditions = True
End If
End Sub

========================================================

I call the Sub from this code:

First methode:
=============

MaxSpecification(Me.form)

===
Or
===
Second Methode:
==============

Dim FrmCurrent as From
set FrmCurrent = [Forms]![FrmClient]![FrmAdress]
MaxSpecification(FrmCurrent)

===
Or
===
third Methode:
==============

MaxSpecification(Me.Name)

Did somebody have in idea why I have the message:

Incompibale type when the compiler Arrive to
MaxSpecification(Me.form) or MaxSpecification(FrmCurrent)

Thanks
 
A

Albert

Try
MaxSpecification(Me)

or
MaxSpecification([Forms]![FrmClient])

Your MaxSpecification requires Form as parameter. Me itself return form
object which running code. [Forms]![FrmClient] returns FrmClient form
object.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top