I've read a little bit about error trapping/handling in Microsoft Access, but it's still confusing to me.
According to the client's business rules, the user must be prevented from accessing the various subforms until all required fields are filled in on the main form. I would like a specific error message displayed (for example, "please fill in the street address"), and then for the focus to be set to that field. If the user enters a field and tries to leave without entering a value, or after removing the existing value, I want the focus to be left there and a specific error message printed.
My problem is that I don't know where the error is coming from. I cannot rely on the value of the field- if the user clears out the value, the VB code only sees the last valid value, not "". After reading up, it looked like Err.Source was the answer, that I could slip this into my MsgBox and as the DoCmd.GoToControl parameter; but in the Form_Error function, these are both blank when I try to access them! Any ideas?
According to the client's business rules, the user must be prevented from accessing the various subforms until all required fields are filled in on the main form. I would like a specific error message displayed (for example, "please fill in the street address"), and then for the focus to be set to that field. If the user enters a field and tries to leave without entering a value, or after removing the existing value, I want the focus to be left there and a specific error message printed.
My problem is that I don't know where the error is coming from. I cannot rely on the value of the field- if the user clears out the value, the VB code only sees the last valid value, not "". After reading up, it looked like Err.Source was the answer, that I could slip this into my MsgBox and as the DoCmd.GoToControl parameter; but in the Form_Error function, these are both blank when I try to access them! Any ideas?