can i assign a control as a constant?

Can i assign a control as a constant?

In my public functions i often have a recourse to one and the same controls of one and the same main form and subform.
The main form is called FOrderInformation and the subform is called FOrder details extended.

Here is an example:

Dim Main As Form
Dim MySubform As Form
Dim Quantity As Control
Dim cartons As Control
Dim office As Control
Dim customer As Control
Dim liters As Control
Dim size As Control
Dim items1 As Control
Dim unitprice As Control
Dim extendedprice As Control
Dim strWhere As String
Dim strCondition As String

Set Main = [Forms]![FOrderInformation]
Set MySubform = [Forms]![FOrderInformation]![Forder details extended].[Form]
Set Quantity = [Forms]![FOrderInformation]![Forder details extended].[Form].[Quantity]
Set cartons = [Forms]![FOrderInformation]![Forder details extended].[Form].[cartons]
Set size = [Forms]![FOrderInformation]![Forder details extended].[Form].[size]
Set liters = [Forms]![FOrderInformation]![Forder details extended].[Form].[liters]
Set items1 = [Forms]![FOrderInformation]![Forder details extended].[Form].[items1]
Set unitprice = [Forms]![FOrderInformation]![Forder details extended].[Form].[unitprice]
Set extendedprice = [Forms]![FOrderInformation]![Forder details extended].[Form].[extendedprice]
Set customer = Main![Customerid]
strCondition = "ProductID=" & MySubform.Productid
strWhere = " WHERE " & strCondition

I often use these controls in different functions, say liters = Quantity * size and so on, for may different occasions.
Each time, for each function i have to declare the above controls with Dim and Set.
Is there any way to simplify my work, and make all these variables constant, or to call them somehow in my functions
from a given stored place?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!