Link to home
Create AccountLog in
Avatar of developingprogrammer
developingprogrammer

asked on

show list of possible arguments for parameter

hey guys, you know when you type a line of code like

DoCmd.OpenForm "someform",THIS ARGUMENT

intellisense will show what are the possible constants we can put for THIS ARGUMENT.

i would like to do the same for my custom functions. is this possible? how do i show and restrict the arguments passed into my parameters? thanks guys!! = ))

edit: and how do i set constants for my function parameters like acNormal, acLayout so that the user of the function can just choose the constants? thanks guys!!
Avatar of edtechdba
edtechdba
Flag of United States of America image

If you have a drop down combo box in your form and would like to enable the user to select their layout then you should be able to do something like this.

Sub routine example:
Sub YourSubRoutineName ()

Dim sLayout As String

  If <your combo box value = "acNormal"> Then  
    sLayout = "acNormal"
  Else
    sLayout = "acLayout"
  End If

  ' pass in user layout pref. into the function
  Call OpenYourForm (sLayout)
    
End Sub

Open in new window


Function example:
Function OpenYourForm (sLayout As String) As String

  DoCmd.OpenForm "someform", sLayout

End Function

Open in new window

And if you'd like for the function to be dynamic for any type of form, you can also pass in the form name from the sub routine into the function as a parameter.

Function example:
Function OpenYourForm (sLayout As String, sForm As String) As String

  DoCmd.OpenForm sForm, sLayout

End Function

Open in new window



And then you would need to update your sub routine to pass the form name into the function.

Sub routine example:
Sub YourSubRoutineName ()

Dim sLayout As String
Dim sForm As String

  If <your combo box value = "acNormal"> Then  
    sLayout = "acNormal"
  Else
    sLayout = "acLayout"
  End If

sForm = <your form name>

  ' pass in user layout pref. into the function
  Call OpenYourForm (sLayout,sForm)
    
End Sub

Open in new window

Avatar of developingprogrammer
developingprogrammer

ASKER

thanks edtechdba!

hrmm i'm refering more to code.

I have a customer function with the signature

Public Function Test(Byref strCountry as String) as String

when i type this function in other modules or classes, i would like intellisense in VBE to show me what are the options i can use for strCountry, just like what it does for DoCmd.OpenForm "frmForm",selectable arguments

so it's a purely developer writing code question, no interaction with the user nor forms.
ASKER CERTIFIED SOLUTION
Avatar of Bitsqueezer
Bitsqueezer
Flag of Germany image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Whao, once again super super cool!!!! You're seriously amazing Christian!!! And that's already an understatement!! = ))))

Let me get MZ Tools installed tomorrow and latch on to everything you've taught me so far ok? Thanks Christian!!! I'll reply soon!! = ))
I'm glad if I could help you...:-)
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Whao..... Brain meltdown.... Too unbelievable everything you know ha Christian = ) brain will start up soon again though haha = )
Not so much as you think. If you are 30 years in the business you will know the same...;-))
Now reboot your brain unhurriedly...;-)

I think you're on a good way and you'll get that all so next time you're the one who help others with your experience.
Thanks Christian, you're really fantastic and boy, I really do appreciate all your help. Hey I'm really excited starting using MZ tools and the entire FMS total access ultimate suite! Once I learn those I will go to the tools you shared, I think they will probably overlap quite a bit. But I think I can implement everything you've taught me now. Hrmm, some experts think that my "the ultimate access architecture" is a bit too high level / nebulous, but I think that is the entire thing - I'm trying to define the meta process in HOW to even THINK (sorry for the caps, typing on iPhone without rich HTML) about architecting a swappable reusable scalable customisable application = ) I really feel I've struck gold with this design. At least for me, it's the ultimate breakthrough for now, the culmination of all the concepts you've shared with me, starting from MUST USE MEANINGLESS KEY AS PRIMARY KEY!!!! Hahaha, my gosh I'm so glad I listened!!!!! Haha = PP = )))))

Yup I will definitely help others next time, whether on EE or other ways in my life for sure!! I'm doing it already!! = ))
whao superb Christian! thanks for pointing out the bugs!! i wouldn't have known and it would have caused me massive headaches (and heartaches as well!!)

whao cool tip for the enums to string literals!

yup i just saw the MZ Tools select case code formation for enums = ) going through MZ Tools now

yup i read through Cpearson's enum webpage. his articles are always super good ha = ) though i've spotted critical typo errors before (critical in that it changes the meaning to a non-thinking reader haha)

Cpearson's article did point out the first and last enum values, but he didn't point out the we could creatively use the last enum as a count ha = ) yup and your last enum value because it adds 1 to the previous enum (due to you not defining custom values for the enum), it gives us an accurate count of the enums without having to add 1 = )
the next thing i really really really have to do is go through your hide column solution for my generic form.

but the most important thing now to do is to create that navigation interface and the provider to the navigation interface. that would form the backbone of my entire app = ) thanks Christian once again!! = ))
Hi,

I'm glad if I could help you.

I understand you very well, I also always try to do things as generic as possible to get reusable code. While this is always a good idea it also always costs more time then doing thing "the primitive way" by simply writing some lines of code, maybe similar code x times although you could also use a function.
But I'm afraid you will also learn in future that this way is often not the wanted way of your customers as it sometimes takes too much time. So stay with this way as long as you can but be prepared that you must also come to the right decision sometimes when it's not the right way to fulfill a timeline your customer gave to you.

Enums: If you want to see "enums in action" where heavily, maybe this article is of interest for you where I tried to create a little SQL in VBA method:

"LINQ for VBA" and Typed Tables, Queries and Field Names using VBA

Cheers,

Christian
Thanks Christian, that's why I feel somehow you always know what I'm thinking about and can guide me so accurately = )

For the reusable code part, I'm also trying to come up with a template that I can rapidly develop applications.

So on 2 fronts is that
1) I'm very very concerned about getting my speed of coding up - this not only writing generic code but making my mind full of generic templates AND using tools like MZ tools that put in error handlers etc as well
2) save time by allowing change / new specs I didn't foresee at the beginning.

I think this templatised way of thinking (faster coding) and flexibility (reducing reworking) will together save even more time = )

Ok am excited to check out your article! Let me go through it soon!! = ))
1) templatised ways
2) reduce rework
3) i forgot to mention this - TOOLS!! If I have 6 hours to chop down a tree, I'll spend 5 sharpening my axe = )

Thanks Christian!!
Omg your LINQ for VBA looks SUPER cool!!!!
This little experiment was one of my tries to create a generic way of handling SQL strings in VBA and standard table and field constants which are compiler friendly...:-)
Ha it reminds me of a video I watched last time on an interview of a programmer who also wrote a LINQ project for one of the languages, can't remember which one but boy was he treated like a superstar in the video ha, -- your LINQ project reminds me of him being you! = ))
Hi,

don't know if you ever used the real LINQ in VB.NET for example - this is a really big improvement as you can do a kind of query with different kind of objects (not only database objects, also works with collections and more) and it is easy to use and fast. So whoever has invented that and implemented it successful into an existing language (and not onle VB.NET, also C# and more) must be a really good programmer, on a really higher level than our VBA projects.
My "LINQ" is only a small try to have a kind of "simulation" of the real LINQ to be able to use some SQL commands easier, nothing more. Can't be really compared to the real LINQ...:-)

Cheers,

Christian