title: Is it possible to turn a string into an object reference?
body: <p>I'm trying to make something a little more generic in an Access 2K7 database.  I've got a form that I'm passing some info to using OpenArgs.  I'm passing a form name, subform name and field name, so the field can be populated.</p>
  
  <p>I'm running into trouble "rebuilding" the reference to the field.  I've tried the following, but VBA doesn't like it:</p>
  
  <pre><code>Dim strForm, strField, strSubForm As String
  Dim frm As Form
  
  strForm = Left(Me.OpenArgs, InStr(Me.OpenArgs, "|") - 1)
  Brk1 = Mid(Me.OpenArgs, InStr(Me.OpenArgs, "|") + 1)
  strField = Left(Brk1, InStr(Brk1, "|") - 1)
  strSubForm = Mid(Brk1, InStr(Brk1, "|") + 1)
  
  X = "Forms!" &amp; strForm
  Y = X &amp; "!" &amp; strSubForm
  Z = Y &amp; "!" &amp; strField
  frm(Z) = Me.Calendar0.Value
  </code></pre>
  
  <p>The object of this exercize is to pass the value of the calendar (Me.Calendar0.Value) to the field on the subform (Forms!strForm!strSubForm!strField).  I just can't figure out how to write that in a way that VBA will accept it.  I'm getting an "Object variable or With block variable not set" error.</p>