Referring to a form field in a module

  • Thread starter Thread starter Karen Hart
  • Start date Start date
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!
 
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)
 
Back
Top