Also, this line
Code:
DLookup("[tarikhtavalod]", "[gosfandha]", "code = Forms!nabod!codegosfand") = Null Then
is saying: lookup the field "[tarikhtavalod]" in table/query "[gosfandha]" where the field "Code" is equal to the string "Forms!nabod!codegosfand". I don't think the code field has anything close to that string.
You have a value in a control that you want to search for, so you have to concatenate the value from that control to the criteria.
If the field "code" is a text type field, delimiters are required.
Code:
If DLookup("[tarikhtavalod]", "[gosfandha]", "code" = '" & Forms!nabod!codegosfand & "'") = Null Then
If the field "code" is a number type field, NO delimiters are required.
Code:
If DLookup("[tarikhtavalod]", "[gosfandha]", "code = " & Forms!nabod!codegosfand ) = Null Then
Then there is the NULL issue. As Linq said, you have to use the IsNull() function.
Now the line for a text type field looks like
Code:
If IsNull(DLookup("[tarikhtavalod]", "[gosfandha]", "code = '" & Forms!nabod!codegosfand & "'")) Then
Expanded, the criteria clause looks like "code = ' " & Forms!nabod!codegosfand & " ' "
And a number type field looks like
Code:
If IsNull(DLookup("[tarikhtavalod]", "[gosfandha]", "code = " & Forms!nabod!codegosfand )) Then