Hi,
I have two tables, Trans_Details and Reference_Master with following fields:
Trans_Details table:
Trans_Id : Autonumber
Trans_Type : String
Trans_Ref : Number (This field has a lookup in table design with field Reference_Id field from Reference_Master table)
Reference_Master table:
Reference_Id : Autonumber
Reference_Desc : String
I have a form on which user is expected to enter value for Trans_Type and a combo-box for selecting Trans_Ref. This combo-box entry can be left blank by the user (basically, it is not mandatory to select Reference value). I have a command button on this form which when clicked will duplicate the recently entered record from Trans_Details table as a new record.
In the VBA code which I have written to assign current record values to variables, insert new record and then update field values in new record with variables works fine if Trans_Ref field is not null in the record being copied. If this field is blank (null), while setting this value to a variable, I get an error "Invalid Use of NULL". I tried using NZ(Trans_Ref) while assigning it to variable. In this case, while inserting the record (rather while updating field value with variable in newly inserted record), it gives an error that "There has to be an entry in table Reference_Master for corresponding value in Trans_Ref. Can not save record at this time".
Are there any thoughts on where I am making a mistake?
Thanks in advance,
Regards,
--Psatkar
I have two tables, Trans_Details and Reference_Master with following fields:
Trans_Details table:
Trans_Id : Autonumber
Trans_Type : String
Trans_Ref : Number (This field has a lookup in table design with field Reference_Id field from Reference_Master table)
Reference_Master table:
Reference_Id : Autonumber
Reference_Desc : String
I have a form on which user is expected to enter value for Trans_Type and a combo-box for selecting Trans_Ref. This combo-box entry can be left blank by the user (basically, it is not mandatory to select Reference value). I have a command button on this form which when clicked will duplicate the recently entered record from Trans_Details table as a new record.
In the VBA code which I have written to assign current record values to variables, insert new record and then update field values in new record with variables works fine if Trans_Ref field is not null in the record being copied. If this field is blank (null), while setting this value to a variable, I get an error "Invalid Use of NULL". I tried using NZ(Trans_Ref) while assigning it to variable. In this case, while inserting the record (rather while updating field value with variable in newly inserted record), it gives an error that "There has to be an entry in table Reference_Master for corresponding value in Trans_Ref. Can not save record at this time".
Are there any thoughts on where I am making a mistake?
Thanks in advance,
Regards,
--Psatkar