Here it is. The only form we are dealing with at the moment is frmHousingEvents. As soon as txtCCS is updated you get the Address error.
Here it is. The only form we are dealing with at the moment is frmHousingEvents. As soon as txtCCS is updated you get the Address error.
The problem is you're populating a bound field when you select a new client. I altered it slightly and populated the client id field only if the record is a new record and it's also 'dirty' (something is entered in the record)
Here's your database back and it's behaving closer to what you want I think. There's a function to test the record in the ON EXIT property of each data entry field and I've locked down the client ID field so it can't accidentally be overwritten.
Your other option here is to make this form form/subform arrangement so the foreign key to your client table is always enforced.
PSH Outcomes Demo.zip
p.s. I don't use bound forms so someone may have a better solution than mine
Well, it works. A couple of observations. In yours the AfterUpdate event does nothing. I'm curious how the form "knows" the value of cboClientID has changed and to requery the data? I put in a button to set the value of cboClientID and txtFirstName to "", but the form wouldn't update to I did a me.requery.
Thank you for your solution. I welcome any other suggestions.
The after update event of cboClientID does do something.
It undoes the current record (if the current record hasn't been saved)
it requeries the form to handle the new selected client
then goes to the 'new' record on the newly requeried form
You can't set the value of cboclientID and txtfirstname to "" and get reliable results, they have to be NULL or you will get inconsistent results at best and errors at worst. Null is NOT the same as an empty string ("").
If you want to clear the form your button click should be something like
me.undo
me.cboclientid = null
me.txtfirstname = null
me.requery
Yes I can see that now. I misread the code.
I put something very near what you have in my Undo button except for using the nulls which I have corrected.
Thanks again.
Paul
Yeah, it's like you're Data Entry property is yes and after the combo update, you're trying to move off the record. Need to see more of the form and db; the visual just shows the record is in edit mode.