Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help resolving the cause of a data entry Error Message

Status
Not open for further replies.

DPROMICS

Technical User
Nov 5, 2003
108
US
I need help resolving the cause and the fix for an Error Message I get when teh first character is entered in to a text field of a subform.

The error message is: "You tried to assign the Null value to a variable that is not a variant data type."

The Details:

1) I have a form. On the form is a subform with text
fields where text is entered in to a new record.

2) The main and the subform on it are both associated
with the same table.

3) When I click on the "add new record" command button on
the main form, the focus is set to the first text field
on the subform. The text field on the subform now has
the cursor verticle bar on it.

When I press any text character on the keyboard I get
an error message. The error messages is:

"You tried to assign the Null value to a variable that
is not a variant data type."

When I click on the OK button on the error message's
window, the character I pressed on the keyboard,
appears in the text box. I can then enter more
characters with no further error messages. It doesn't
matter what text field I start with on the subform.
I still get the same error message.

I have looked through the Access programming books and
the like and haven't been able to figure out the cause
and the resolution to this problem.

Any body out there that can help me with this problem?

Best Regards,
 
Have a look at ALL the event procedures ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV

OK. I found the problem by looking at another subform that also has a command button to add a new record to another table in my Access app.

The original event function that starts the new record data entry function:
- - - - - - - - - - - - - - - - - - - - - - - - - -
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
Frm_PT_Data_Subform.Visible = True

' Create New Record for the New Patient to be entered in to
the Database
DoCmd.GoToRecord , , acNewRec

' Set Focus to the Patient Demographic Data Subform
[Frm_PT_Data_Subform].SetFocus

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
- - - - - - - - - - - - - - - - - - - - - - - - - -

The command line: [Frm_PT_Data_Subform].SetFocus

needs to come before: DoCmd.GoToRecord , , acNewRec

rather than after it. Moving the add new record command line to where it should be in the function resolved the data entry problem.

I figured this out by looking at another add new record event function for another subform and table in my Access app. That event function does work as it should.

Duhhhhh . . . on my part. For some reason I hadn't thought about (yet) looking at the other add new record command button event functions in my Access app.

Thanks for the help I really do appreciate it.

Best Regards,

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top