What I am trying to do is assign values to form controls via a public sub procedure called on by a form.
So in testing this is what I have done:
The first msgbox returns the formname.
The second msgbox returns the the value in cboPosition
The third msgbox I am attempting to get the same result as the second msgbox, but it returns an error message "form 'frmNewSample!cboPosition' not found"
Public Sub PosUpdate(FormName As String)
'FormName = frmNewSample
MsgBox FormName
MsgBox Forms!frmNewSample!cboPosition.Value
MsgBox Forms(FormName & "!cboPosition").Value
End Sub
So in testing this is what I have done:
The first msgbox returns the formname.
The second msgbox returns the the value in cboPosition
The third msgbox I am attempting to get the same result as the second msgbox, but it returns an error message "form 'frmNewSample!cboPosition' not found"
Public Sub PosUpdate(FormName As String)
'FormName = frmNewSample
MsgBox FormName
MsgBox Forms!frmNewSample!cboPosition.Value
MsgBox Forms(FormName & "!cboPosition").Value
End Sub