Dlookup Works but isnlt populating table

samjh

Registered User.
Local time
Today, 17:47
Joined
Jan 10, 2013
Messages
64
Hi,

I have a form that has been created from a table.
One of the boxes in the form is the IncomeSubjective, which I have used a Dloopup within the On Current event to get the correct Income Subjective, which it is doing, as I can see the subjective in the box.

However when I go to save the form, it tells me that the field "tblIncome.IncomeSubjective' cannot contain a null value because the Required property for this fiels is set to True. Enter a value in this field.

I don't understand as it isn't null I can see it there. I am wondering whether there is somthing missing from my code (below) that passes the code to the correct place???

Private Sub Form_Current()
Me.IncomeSubjective = DLookup("[Subjective]", "tblIncomeSubjective", "[ExpSubjective] = '" & Forms![frmCommitments]![cmbSubjective] & "'")
End Sub

Any help would be great.
 
Hello samjh..
I could not see anything wrong with the code.. Except for the fact it could use a Nz(), as it is possible that DLookUp would return a Null value..
Code:
Private Sub Form_Current()
    Me.IncomeSubjective = [URL="http://www.techonthenet.com/access/functions/advanced/nz.php"]Nz([/URL]DLookup("[Subjective]", "tblIncomeSubjective", "[ExpSubjective] = '" & Forms![frmCommitments]![cmbSubjective] & "'"),"N/A")
End Sub
But your description says that you do get a value in the text box.. I could not recreate your problem, so is it possible to upload a stripped down version of your DB?
 
Thank you for your reply, however I have fixed it. I had saved the Income Subejctive box as being unbound. It's fixed and working now.
 
Ah, that's better now. Glad you got it sorted. Good luck :)
 

Users who are viewing this thread

Back
Top Bottom