Hi,
I'm not sure if this is possible but I'm trying to insert a number that's generated from a DLookup into a field in my table but only if the field is null. I'm getting a syntax error with the following code but if I remove the "varx" and the last Where clause it update the field. Can anyone help me with this or a better way of doing it. Thanks in advance.
Private Sub Form_Close()
Dim varx As String
varx = DCount("[Pay_Number]", "Trust Staff", "Pay_Number =[Forms]![FrmAddStaff]![PAYNO]")
CurrentDb.Execute "UPDATE [trust staff] SET additpayno= varx WHERE Pay_Number= Forms!frmaddstaff!PAYNO and Where additpayno = null"
I'm not sure if this is possible but I'm trying to insert a number that's generated from a DLookup into a field in my table but only if the field is null. I'm getting a syntax error with the following code but if I remove the "varx" and the last Where clause it update the field. Can anyone help me with this or a better way of doing it. Thanks in advance.
Private Sub Form_Close()
Dim varx As String
varx = DCount("[Pay_Number]", "Trust Staff", "Pay_Number =[Forms]![FrmAddStaff]![PAYNO]")
CurrentDb.Execute "UPDATE [trust staff] SET additpayno= varx WHERE Pay_Number= Forms!frmaddstaff!PAYNO and Where additpayno = null"