You tried to assign the null value to a variable error. (1 Viewer)

JustinS

Member
Local time
Today, 11:17
Joined
Apr 11, 2020
Messages
58
I've looked through the archives for posts about this error, but I can't get a good handle on what is causing it in my situation. I have a main form with currently one subform, there will be another subform in the future once I can get this error sorted. The subform is used to create a test record in which entity information and test data are entered. The main form is takes the test information from the subform and conducts a statistical analysis on them.

So here is the problem. When I first select any value on the subform to create a new entity record I get the "you tried to assign the null value to a variable" error. The subform is linked to the main form by Entity ID and Unit ID. Once I select ok on the the message box I am allowed to continue entering the information for the entity and test results. All other data transfer code works fine. The only problem is the error message.

Does anyone have experience with this issue or a solution to this problem?

One other component to this problem that I have just noticed is that when I try to create a new record with the subform opened independently it is trying to create records with ID's that have already been created. For instance it is trying to create ID#12, which is already a current record, rather than creating a new one which would be say ID# 212. Could this be involved in the problem?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:17
Joined
Oct 29, 2018
Messages
21,485
Hi. Can you post a demo version of your db? Are you using any code to assign the record or values in them? If so, we may have to see them.
 

JustinS

Member
Local time
Today, 11:17
Joined
Apr 11, 2020
Messages
58
@theDBguy, here is a dumbed down version of my database. I got the new record issue sorted. I think the problem with that occurred when I was playing around with the master/child links. The only problem left is the original error that I discussed above.

Thank you for your help on this.
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 08:17
Joined
Oct 29, 2018
Messages
21,485
@theDBguy, here is a dumbed down version of my database. I got the new record issue sorted. I think the problem with that occurred when I was playing around with the master/child links. The only problem left is the original error that I discussed above.

Thank you for your help on this.
Thanks. Since we're not familiar with your database, can you please provide a step-by-step guide on how to duplicate the problem?
 

JustinS

Member
Local time
Today, 11:17
Joined
Apr 11, 2020
Messages
58
Just go to the main form “commercial gas stats”, something like that I don’t have it open right now. Create a new record on the main form and try to select a value from the “entered by” combo box, first field top left, on the subform. As soon as you select the value the error message should pop up.

Please let me know if you have more questions. The main form and subform are a little rough right now as I am still working on the concept and application of the form, so please excuse the mess.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:17
Joined
Oct 29, 2018
Messages
21,485
Just go to the main form “commercial gas stats”, something like that I don’t have it open right now. Create a new record on the main form and try to select a value from the “entered by” combo box, first field top left, on the subform. As soon as you select the value the error message should pop up.

Please let me know if you have more questions. The main form and subform are a little rough right now as I am still working on the concept and application of the form, so please excuse the mess.
Hi. Thanks. Here's what I did:
  1. Opened the form Commercial Gas Claim Stats
  2. Clicked on the New Record button on the Main form
  3. Entered the value 8 in the Unit 1 ID textbox on the main form
  4. Selected a value from the Test Entered By combobox on the subform
  5. No error message (you would get an error message if you didn't put a value in the Unit 1 ID textbox first because the subform is linked to it.
Hope that helps...
 

JustinS

Member
Local time
Today, 11:17
Joined
Apr 11, 2020
Messages
58
I think it does. Forgive my ignorance, but is there a rule that you have to interact with the main form before entering information in the subform?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:17
Joined
Oct 29, 2018
Messages
21,485
I think it does. Forgive my ignorance, but is there a rule that you have to interact with the main form before entering information in the subform?
Yes. The main form is supposed to represent the parent record, and the subform is supposed to represent the child records. Your current setup may be backwards.
 

JustinS

Member
Local time
Today, 11:17
Joined
Apr 11, 2020
Messages
58
That is definitely the problem then. As always, thanks for the help.
 

Users who are viewing this thread

Top Bottom