If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Form_Current() - two statements conflicting?
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 |
#2
|
|||
|
|||
Form_Current() - two statements conflicting?
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 -- _________ Sean Bailey "scottyboyb" wrote: 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 |
#3
|
|||
|
|||
Form_Current() - two statements conflicting?
Thank you, that's the ticket. I did not know I could move those pieces around
like that. Best, Scott "Beetle" wrote: 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 -- _________ Sean Bailey "scottyboyb" wrote: 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 |
Thread Tools | |
Display Modes | |
|
|