TSIsolutions
MIS
Good Afternoon,
Maybe someone can help me with this one...
It's actually simple (or so it seems) but I can't seem to figur it out.
I have a procedure called cmdCloseForm_Click(). This procedure closes the form. I have included in this procedure a Call Statement to another procedure. The Other procedure, ValidateRecord(), checks certain fields for errors. I've simplified it and it looks something like this:
Private Sub cmdCloseForm_Click()
Call ValidateRecord()
Docmd.Close, acform, "ThisForm"
End Sub
...
Public Sub ValidateRecord()
If isNull(Me.field1) Then
MsgBox "ERROR"
Else
MsgBox "No ERRORS"
End If
End Sub
What I would like my code to do is stop the form from closing if Me.field1 is Null. I tried using an Exit Sub in the ValidateRecord procedure but it only prevents the rest of that procedure from executing, not the code in the cmdCloseForm. the End statement worked but it also deleted all of the information loaded in my variables.
I know I can pass a variable to the cmdCloseForm procedure (like True or False) and include an If statement in the cmdCloseForm procedure but I have quite a few of these examples around my application and I was wondering if there was an easier way around it. I'm sure there's an easier way to do this.
Thanks,
Lawrence
"If you don't succeed - CTRL + ALT + DELETE "
Maybe someone can help me with this one...
It's actually simple (or so it seems) but I can't seem to figur it out.
I have a procedure called cmdCloseForm_Click(). This procedure closes the form. I have included in this procedure a Call Statement to another procedure. The Other procedure, ValidateRecord(), checks certain fields for errors. I've simplified it and it looks something like this:
Private Sub cmdCloseForm_Click()
Call ValidateRecord()
Docmd.Close, acform, "ThisForm"
End Sub
...
Public Sub ValidateRecord()
If isNull(Me.field1) Then
MsgBox "ERROR"
Else
MsgBox "No ERRORS"
End If
End Sub
What I would like my code to do is stop the form from closing if Me.field1 is Null. I tried using an Exit Sub in the ValidateRecord procedure but it only prevents the rest of that procedure from executing, not the code in the cmdCloseForm. the End statement worked but it also deleted all of the information loaded in my variables.
I know I can pass a variable to the cmdCloseForm procedure (like True or False) and include an If statement in the cmdCloseForm procedure but I have quite a few of these examples around my application and I was wondering if there was an easier way around it. I'm sure there's an easier way to do this.
Thanks,
Lawrence
"If you don't succeed - CTRL + ALT + DELETE "