I need help resolving the cause of a data entry problem on a form/subform.
The details . . .
1) This Access application is being created under Access
2000.
2) In my Access application I have a main form called
ECMR_Main.
The main form ECMR_Main allows selecting a patient from
its associated table.
The table the form is associated with is called
Tbl_PT_Demographics.
The table contains patient demographic data.
The table is the primary table of my Access
application.
There are other tables in the Access application that
are linked to this table in a "One To Many" relationship.
The table Tbl_PT_Demographics table’s index is called
PT_DB_Number.
3) The main form ECMR_Main has a subform
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data on it.
The subform on the main form is normally set to hidden.
The subform,
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data, is also
associated to the same table, Tbl_PT_Demographics, as
the main form ECMR_Main.
The subform,
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data, has its
parent-child relationship defined.
On the subform’s property sheet the Link Child Fields is
set to PT_DB_Number. The Link Master Fields is also set
to PT_DB_Number. Remember that the main and subform are
associated to the same table, Tbl_PT_Demographics.
4) On the main form, ECMR_Main, there is a command button
labeled Add New Patient, that when clicked on allows
entering a new patient in to the patient demographic
data table, Tbl_PT_Demographics.
5) When the command button is clicked on it transfers the
focus to a subform
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data that is
on the main form ECMR_Main.
When the command button is clicked on, its "On-Click"
command contains the code to:
1) Changes the Subform,
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data,
from hidden to visible.
2) Sets the focus to the subform,
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data.
And by default to the first field on the subform,
the patient’s last name field, Tbo_PT_Name_Last.
3) Creates a new patient record in the table
Tbl_PT_Demographics.
This is the VB code for the Add a New Patient command button’s “On Click”:
- - - - - - - - - - - - - - - - - - - - - - - - - -
Private Sub Cmd_Add_New_Patient_Click()
On Error GoTo Err_Cmd_Add_New_Patient_Click
' On Add New Patient insure that the Patient Data subform is visible
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data.Visible = True
' Set Focus to the Patient Demographic Data Subform
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data.SetFocus
' Create New Record for the New Patient to be entered in to the Database
DoCmd.GoToRecord , , acNewRec
Exit_Cmd_Add_New_Patient_Click:
Exit Sub
Err_Cmd_Add_New_Patient_Click:
MsgBox Err.Description
Resume Exit_Cmd_Add_New_Patient_Click
End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - -
When the application is running, the problem is that when one enters the first character of a new patient's last name, in the text filed Tbo_PT_Name_Last, an error message is immediately displayed. The error message is:
" You tried to assign the Null value to a variable that is not a Variant data type."
If one clicks OK, the error message window closes and the character entered appears in the text box. One can then continue to add data and then save the new patient's demographic data with no additional error messages. The new patient’s data is added to the table Tbl_PT_Demographics.
In the VB code it doesn’t matter if the focus is set to the subform before a new record is created or after it. The same error message is displayed.
OK, Is there something else that needs to be added to the Add New Patient command button’s code? May be a Me.xxx or something like that or something else?
Is there an inherent problem with a subform on a mainform where both forms are associated with the same table and the subform’s Parent and Child fields are the same table’s index?
Should I setup this code significantly differently than it is? My “gut” programmer’s feeling is that this arrangement of main and subform isn’t a problem. It’s just a matter of setting up the necessary underlying VB code correctly.
OK. Does anybody have a solution for this or any ideas on how to resolve this data entry problem?
If anyone wants to see the main-subform screen shot of this application in order to get a better feel for what and why I am doing it this way, go to: The old adage, “A picture is worth a thousand words” is very, very, true. NOTE: This "orphan" web page displays only an image of the main form of my Access application. There are no advertisements for anything on it.
Best Regards,
The details . . .
1) This Access application is being created under Access
2000.
2) In my Access application I have a main form called
ECMR_Main.
The main form ECMR_Main allows selecting a patient from
its associated table.
The table the form is associated with is called
Tbl_PT_Demographics.
The table contains patient demographic data.
The table is the primary table of my Access
application.
There are other tables in the Access application that
are linked to this table in a "One To Many" relationship.
The table Tbl_PT_Demographics table’s index is called
PT_DB_Number.
3) The main form ECMR_Main has a subform
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data on it.
The subform on the main form is normally set to hidden.
The subform,
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data, is also
associated to the same table, Tbl_PT_Demographics, as
the main form ECMR_Main.
The subform,
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data, has its
parent-child relationship defined.
On the subform’s property sheet the Link Child Fields is
set to PT_DB_Number. The Link Master Fields is also set
to PT_DB_Number. Remember that the main and subform are
associated to the same table, Tbl_PT_Demographics.
4) On the main form, ECMR_Main, there is a command button
labeled Add New Patient, that when clicked on allows
entering a new patient in to the patient demographic
data table, Tbl_PT_Demographics.
5) When the command button is clicked on it transfers the
focus to a subform
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data that is
on the main form ECMR_Main.
When the command button is clicked on, its "On-Click"
command contains the code to:
1) Changes the Subform,
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data,
from hidden to visible.
2) Sets the focus to the subform,
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data.
And by default to the first field on the subform,
the patient’s last name field, Tbo_PT_Name_Last.
3) Creates a new patient record in the table
Tbl_PT_Demographics.
This is the VB code for the Add a New Patient command button’s “On Click”:
- - - - - - - - - - - - - - - - - - - - - - - - - -
Private Sub Cmd_Add_New_Patient_Click()
On Error GoTo Err_Cmd_Add_New_Patient_Click
' On Add New Patient insure that the Patient Data subform is visible
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data.Visible = True
' Set Focus to the Patient Demographic Data Subform
SubFrm_PT_Demographic_Pacemaker_ICD_Device_Data.SetFocus
' Create New Record for the New Patient to be entered in to the Database
DoCmd.GoToRecord , , acNewRec
Exit_Cmd_Add_New_Patient_Click:
Exit Sub
Err_Cmd_Add_New_Patient_Click:
MsgBox Err.Description
Resume Exit_Cmd_Add_New_Patient_Click
End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - -
When the application is running, the problem is that when one enters the first character of a new patient's last name, in the text filed Tbo_PT_Name_Last, an error message is immediately displayed. The error message is:
" You tried to assign the Null value to a variable that is not a Variant data type."
If one clicks OK, the error message window closes and the character entered appears in the text box. One can then continue to add data and then save the new patient's demographic data with no additional error messages. The new patient’s data is added to the table Tbl_PT_Demographics.
In the VB code it doesn’t matter if the focus is set to the subform before a new record is created or after it. The same error message is displayed.
OK, Is there something else that needs to be added to the Add New Patient command button’s code? May be a Me.xxx or something like that or something else?
Is there an inherent problem with a subform on a mainform where both forms are associated with the same table and the subform’s Parent and Child fields are the same table’s index?
Should I setup this code significantly differently than it is? My “gut” programmer’s feeling is that this arrangement of main and subform isn’t a problem. It’s just a matter of setting up the necessary underlying VB code correctly.
OK. Does anybody have a solution for this or any ideas on how to resolve this data entry problem?
If anyone wants to see the main-subform screen shot of this application in order to get a better feel for what and why I am doing it this way, go to: The old adage, “A picture is worth a thousand words” is very, very, true. NOTE: This "orphan" web page displays only an image of the main form of my Access application. There are no advertisements for anything on it.
Best Regards,