[AccessD] VBA Function with parameters
Stuart McLachlan
stuart at lexacorp.com.pg
Fri Nov 5 01:08:26 CDT 2021
Or even:
Enum CarMakes
Ford = 1
Toyota = 2
Suzuki = 4
End Enum
Function SHowCar(cm As CarMakes) As Long
Dim s As String
If cm And 1 Then s = "Ford "
If cm And 2 Then s = s & Toyota "
If cm And 4 Then s = s & "Suzuki"
MsgBox s
End Function
...
showcar(Suzuki or Toyota)
...
On 5 Nov 2021 at 15:34, Stuart McLachlan wrote:
> Yep, Intellisense groks ENUMS.
>
> Enum CarMakes
> Ford
> Toyota
> Suzuki
> End Enum
>
> Function ShowCar(cm As CarMakes) As Long
> Dim s As String
> Select Case cm
> Case CarMakes.Ford: s = "Ford"
> Case CarMakes.Toyota: s = "Toyota"
> Case CarMakes.Suzuki: s = "Suzuki"
> End Select
> MsgBox s
> End Function
>
> If you type "Showcar(" the VBE will give you the three options
>
>
> On 5 Nov 2021 at 5:00, Paul Hartland via AccessD wrote:
>
> > See answer at bottom of this link, is this what you are after ?
> >
> > https://stackoverflow.com/questions/38250515/vba-restrict-function-a
> > rg uments-to-only-selected-values
> >
> > Paul
> >
> > On Fri, 5 Nov 2021, 04:56 Borge Hansen, <pcs.accessd at gmail.com>
> > wrote:
> >
> > > Hi,
> > > How can I provide parameters to my own function similar to for
> > > example:
> > >
> > > DoCmd.OpenQuery (QueryName, View, DataMode)
> > > where DataMode is optional and can be one of these constants
> > > acAdd
> > > acEdit (default) - which I think allows for adding as well if the
> > > query view make it possible acViewOnly
> > >
> > > So for example
> > > function myFunction(param1, param2)
> > >
> > > where param2 is an optional parameter with a limited set of
> > > values. When the function is being used elsewhere in the app, I
> > > expect the limited set of values for param2 to appear, similar to
> > > for example the docmd.openquery ...
> > >
> > > ??
> > >
> > > /borge
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > https://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
More information about the AccessD
mailing list