As described in the previous post, once defined a public variable and assigned it to a funcion, we are able to use it in a number of different tasks. The trick is the same one, obviously! ;)
Follow these steps:
1) declare into a module the variable as public:
Public MyString As String
2) create a function with an arbitrary name and assign to the function's name the desired value
Public Function CallMyString()
CallMyString = MyString
End Function


3) use the function's name as value or as a part of a string:
CallMyString()
For Instance we could have a text box onto a form called textbox2. Let's assign to the textbox a string value:
form_nameform.textbox2.value = "An arbitrary string " &  CallMyString()
 
What about "snippets"? Snippets are small pieces of code easy and ready to use in Ms-Access applications.
 
Sometime would be very useful to use a VBA variable into a query. The code may generate the variable's value and we could use the variable as query as  filter parameter. Here the steps:
1) declare into a module the variable as public:
Public IDUTENTE As Double
2) create a function with an arbitrary name and assign to the function's name the desired value
Public Function chiamaidutente()
chiamaidutente = IDUTENTE
End Function


3) use the function's name as query criteria:
chiamaidutente()