Howdy, Stranger!

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


can i assign a control as a constant?

freelancefreelance Member Posts: 26

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?


  • Shawn CarterShawn Carter Member Posts: 0

    ____ [ ] free video tutorials and ebooks about | Python JavaScript Java C PL/SQL R Scratch MATLAB Perl Delphi Ruby Assembly Objective-C PHP C# Visual Basic .NET C++ Go Swift Visual Basic VBScript Erlang LabVIEW Crystal Scheme Clojure Prolog Hack Fortran Scala Apex Dart Lua Bash Kotlin ABAP Rust ML Ada SAS Julia FoxPro Transact-SQL Alice Awk F# Lisp D Logo COBOL | ______

Sign In or Register to comment.