Problem with null value assignment (1 Viewer)

ascaife

Registered User.
Local time
Tomorrow, 01:37
Joined
Nov 10, 2008
Messages
50
I have a form with a number of subforms but instead of using tabs, I inserted an unbound subform where the sourceobject changes depending on the command button clicked.

The data displays correctly, however, every time I go to add a new record, I get the error:

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

It then allows me to data enter, but If I go back a record, the new one disappears, and then reappears if I close and reopen the form.

Any ideas?
 

wazz

Super Moderator
Local time
Today, 23:37
Joined
Jun 29, 2004
Messages
1,711
not sure that's a subform problem because of the highlighted parts:

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

check your assignments (slowly step through if possible and see where the error fires). it might be a bit tricky if you actually forgot to make an assignment (hence the null) where one is needed. are you setting master and child links when you change source objects?
 

ascaife

Registered User.
Local time
Tomorrow, 01:37
Joined
Nov 10, 2008
Messages
50
I think it has something to do with the autonumber recordID somehow.

Just tried another approach which was to place the subform directly on my form as a bound control and got the same message, then another message saying I was trying to assign a duplicate value (which I believe was to the autonumber field).

I know I've messed up in my record sources.

The main form recordsource is tblStudentsMain.StudentRecordID

The subform recordsource is qryStudentsCombined which includes all records from tblStudentsMain and includes some other information from tblStudentsOtherInfo, which are fields required on my subform.

I just realised the linked master and child fields are in fact the same field. One is StudentRecordID from the table and the other is the same field from the query.

I think I know what's going on in theory, just not sure how to best design the solution.

Sorry, I'm a bit of a hack at this.......
 

Users who are viewing this thread

Top Bottom