Referring to a form field in a module

K

Karen Hart

I have a module that copies a word processing template file from a source
folder to a destination folder. The source folder is determined by the
contents of a field in a form:

Formname = WordProcessingLocations
Fieldname = TemplateSource

I have tried passing that information on like this in a module, but it isn't
working:

Dim SourceFolder As String
SourceFolder = Forms.WordProcessingLocations.TemplateSource

I hope I am making sense. How do I pass the contents of the field
"TemplateSource" in the form "WordProcessingLocations" to a variable?

Thanks in advance!
 
D

Douglas J. Steele

Dim SourceFolder As String
Dim strControlName As String

strControlName = "TemplateSource"
SourceFolder = Forms.WordProcessingLocations.Controls(strControlName)

In fact, you can even have the form referred to in a variable:

Dim SourceFolder As String
Dim strControlName As String
Dim strFormName As String

strControlName = "TemplateSource"
strFormName = "WordProcessingLocations"
SourceFolder = Forms(strFormName).Controls(strControlName)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top