I have an application that is used to collect clinical data from hospital patients involved in research. Various forms are used to collect specific data, often blood results. When the users enter this data, they may make a mistake and enter a value well outside the normal range. The normal range differs depending on the blood test.
If the value entered is outside the expected range, a PopUp form is opened, and values are passed using OpenArgs. These include the name of the main form, the name of the control, the actual value entered and a 'plain English' name of the type of blood test. The popup form displays the value and plain English name, and asks the user if they are sure they meant that specific value. The user has two command buttons, Accept which simply closes the PopUp, or Reject which returns the focus to the control on the main form.
I am using Access 2007.
The problem is I can't seem to return the focus to the main form. The conventional way to achieve this is:
However, this does not work. Here is the code on my PopUp form:
In the Form Load:
If the user clicks the Reject command button:
The error message is Can't find the field strControlName referred to in your expression.
I have tried declaring fldMyField as a Field in stead of strControlName, but that did not work.
Any ideas where I am going wrong? Thanks for your help.
If the value entered is outside the expected range, a PopUp form is opened, and values are passed using OpenArgs. These include the name of the main form, the name of the control, the actual value entered and a 'plain English' name of the type of blood test. The popup form displays the value and plain English name, and asks the user if they are sure they meant that specific value. The user has two command buttons, Accept which simply closes the PopUp, or Reject which returns the focus to the control on the main form.
I am using Access 2007.
The problem is I can't seem to return the focus to the main form. The conventional way to achieve this is:
Code:
Forms!TheFormName!ControlName.SetFocus
Code:
Option Compare Database Private strFormName As String 'The calling form Private strControlName As String 'The calling control, focus may be returned here Private strValue As String 'The actual value Private strValueType As String 'The type of value, such as ACT or Hb
Code:
Private Sub Form_Load() strFormName = Split(OpenArgs, "~")(0) strControlName = Split(OpenArgs, "~")(1) strValue = Split(OpenArgs, "~")(2) strValueType = Split(OpenArgs, "~")(3) lblTypeOfValue.Caption = strValueType lblValue.Caption = strValue End Sub
Code:
Private Sub cmdNo_Click() Forms(strFormName).Controls!strControlName.SetFocus DoCmd.Close acForm, Me.Name, acSaveNo End Sub
I have tried declaring fldMyField as a Field in stead of strControlName, but that did not work.
Any ideas where I am going wrong? Thanks for your help.
Comment