Boolean variable not holding state



Hello,

I have a form that calls another sub to validate text boxes. I am having
difficulty with getting my boolean variable to carry back to the original
sub.

Code:

**1st module
Private Sub btnSaveRecord_Click()
On Error GoTo Err_btnSaveRecord_Click

Dim validate As Boolean

validateAccount (validate)

If validate = false then
exit sub
else
docmd.save
end if
end sub

**2nd module
Public Sub validateAccount(validate)
If (Account.Value & vbNullString = vbNullString) Then
MsgBox "Account is required!", vbOKOnly
validate = False
Account.Undo
Else
validate = True
End If
End Sub


.



Relevant Pages

  • Re: Code stopped working??!
    ... >> I am writng some code to validate dates entered. ... It compares a date in a cell H12 to the ... >> Private Sub Worksheet_SelectionChange ... >> Dim Workdate, StartDate, ExpirationDate As Date ...
    (microsoft.public.excel.programming)
  • Re: Boolean variable not holding state
    ... Declaration" option, please note that this will affect only new modules that ... I have a form that calls another sub to validate text boxes. ... If (Account.Value & vbNullString = vbNullString) Then ...
    (microsoft.public.access.formscoding)
  • RE: Validation error
    ... Private Sub Form_BeforeUpdate ... On Error GoTo ProcError ... Private Function Validate() As Boolean ...
    (microsoft.public.access.formscoding)
  • RE: Validation error
    ... Private Sub Form_BeforeUpdate ... On Error GoTo ProcError ... Private Function Validate() As Boolean ...
    (microsoft.public.access.formscoding)
  • Code stopped working??!
    ... > I am writng some code to validate dates entered. ... It compares a date in a cell H12 to the ... > Private Sub Worksheet_SelectionChange ... > Dim Workdate, StartDate, ExpirationDate As Date ...
    (microsoft.public.excel.programming)