Module.AddFromString method (Access)
The AddFromString method adds a string to a Module object. The Module object may represent a standard module or a class module.
Syntax
expression.AddFromString (String)
expression A variable that represents a Module object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
String | Required | String | The information that you want to add to the module. |
Return value
Nothing
Remarks
The AddFromString method places the contents of a string after the Declarations section and before the first existing procedure in the module if the module contains other procedures.
To add a string to a form or report module, the form or report must be open in form Design view or report Design view. To add a string to a standard module or a class module, the module must be open.
Example
This example creates a new form and adds a string and the contents of the Functions.txt file to its module. Run the following procedure from a standard module.
Sub AddTextToFormModule()
Dim frm As Form, mdl As Module
Set frm = CreateForm
Set mdl = frm.Module
mdl.AddFromString "Public intY As Integer"
mdl.AddFromFile "C:\My Documents\Functions.txt"
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.