pdvsa
asked on
AfterUpdate Issue
Experts,
I have code running to insert data to a table based on whether or not the [DateOfIssueSB] is Null or Not Null.
If Null then I want to run strSQL = "INSERT INTO tblLCAmendHistory code
If not Null then I dont want to run it.
It seems to run all the time meaning that if it is both NULL and NOT NULL [DateOfIssueSB]. I only want the INSERT to run if NULL.
I had the code on both the AFTERUPDATE and BEFOREUPDATE thinking that I should not have th code on BEFOREUPDATE but rather AFTERUPDATE.
When on BEFOREUPDATE it would not give me the error of "VARIABLE NOT DEFINED" but after putting that code on AFTERUPDATE it gives me the error.
I am thinking that the code should be on the AFTERUPDATE and it will INSERT only when ISNULL [DateOfIssueSB] but I do get the error msg below when doing this.
Any ideas on how to INSERT only if ISNULL [DateOfIssueSB]?
the form is in continous forms mode
untitled.JPG
I have code running to insert data to a table based on whether or not the [DateOfIssueSB] is Null or Not Null.
If Null then I want to run strSQL = "INSERT INTO tblLCAmendHistory code
If not Null then I dont want to run it.
It seems to run all the time meaning that if it is both NULL and NOT NULL [DateOfIssueSB]. I only want the INSERT to run if NULL.
I had the code on both the AFTERUPDATE and BEFOREUPDATE thinking that I should not have th code on BEFOREUPDATE but rather AFTERUPDATE.
When on BEFOREUPDATE it would not give me the error of "VARIABLE NOT DEFINED" but after putting that code on AFTERUPDATE it gives me the error.
I am thinking that the code should be on the AFTERUPDATE and it will INSERT only when ISNULL [DateOfIssueSB] but I do get the error msg below when doing this.
Any ideas on how to INSERT only if ISNULL [DateOfIssueSB]?
the form is in continous forms mode
untitled.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can have Cancel only in Before update event. If you will build code for this event you will see Cancel as parameter of Sub
p.s. your code does run an unconditional insert on line 37: docmd.runsql strSQL.
But the insert is to a different table, depending on me.txtDateOfIssueSB
But the insert is to a different table, depending on me.txtDateOfIssueSB
ASKER
I remvoed the Cancel part
I also had to change the FALSE to TRUE and I think it worked after that or at least when a record is present. Not sure how it will act if new record.
Think I am good for now.
thank you for the help.
Thanks for pointing out that the update is to 2 diff tables. You have a good eye. I forgot I was doing this. I do want it this way though.
I also had to change the FALSE to TRUE and I think it worked after that or at least when a record is present. Not sure how it will act if new record.
Think I am good for now.
thank you for the help.
Thanks for pointing out that the update is to 2 diff tables. You have a good eye. I forgot I was doing this. I do want it this way though.
ASKER
Open in new window