[AccessD] VBA Function with parameters

Stuart McLachlan stuart at lexacorp.com.pg
Fri Nov 5 00:34:10 CDT 2021


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-arg
> 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
> 




More information about the AccessD mailing list