Form_Current() - two statements conflicting?

S

scottyboyb

Greetings,

Here is probably a simple puzzle. I have a form with two Form_Current()
events in it. I think one is not playing well with the other. The form has a
command button that opens a subform filtered to the main form's data. That is
working perfectly. I also have an If statement that hides or reveals a text
box based on a check box being true or false. I have this If statement in
another form and it works perfectly there, but here the form opens with the
text box visible with the check both false. I think it has to do with the
Form_Current_Exit: and Exit Sub lines in the code. Am I correct and if so
what do I do about it? If I am not correct, then does anyone have a suggstion
of what might be wrong? If I am wrong, will I need to post the rest of the
form's code for the ChildForm opening and closing and filtering?

Thanks,
Scott

Here is the code for Form_Current():

Sub Form_Current()

On Error GoTo Form_Current_Err

If ChildFormIsOpen() Then FilterChildForm
Form_Current_Exit:
Exit Sub

If Me!chkBoardMember = False Then
Me!txtPosition.Visible = False
Me!txtPosition.Value = ""
Else
Me!txtPosition.Visible = True
End If

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub
 
B

Beetle

Your If statment is never going to process because you're
exiting the procedure before you ever get there. Move these
lines

Form_Current_Exit:
Exit Sub

further down in the procedure (before the error handler)

Sub Form_Current()

On Error GoTo Form_Current_Err

If ChildFormIsOpen() Then FilterChildForm

If Me!chkBoardMember = False Then
Me!txtPosition.Visible = False
Me!txtPosition.Value = ""
Else
Me!txtPosition.Visible = True
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub
 
S

scottyboyb

Thank you, that's the ticket. I did not know I could move those pieces around
like that.

Best,
Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top