Problem with hiding sub forms

If Me.cbo_Entered_By & "" = "" Then
 
And to follow up on what Rich wrote you just need this:
Code:
Private Sub Form_Current()
   If Me.cbo_Entered_By & "" = "" Then
      Me![TabCtl21].Visible = False
      Me![frm_Member_Appeal].Visible = False
      Me![frm_Letters].Visible = False
      Me![frm_PRC].Visible = False
      Me![lbl_name_select].Visible = True
   Else
      Me![TabCtl21].Visible = True
      Me![frm_Member_Appeal].Visible = True
      Me![frm_Letters].Visible = True
      Me![frm_PRC].Visible = True
      Me![lbl_name_select].Visible = False
   End If
End Sub

Private Sub cbo_Entered_By_Exit(Cancel As Integer)
    Call Form_Current   
End Sub
 
Private Sub cbo_Entered_By_Exit(Cancel As Integer)
Call Form_Current
End Sub

Now that's pretty damn cool, Bob. Had no idea you could do that but now that I see it, it makes perfect sense. :)
 
And to follow up on what Rich wrote you just need this:
Code:
Private Sub Form_Current()
   If Me.cbo_Entered_By & "" = "" Then
      Me![TabCtl21].Visible = False
      Me![frm_Member_Appeal].Visible = False
      Me![frm_Letters].Visible = False
      Me![frm_PRC].Visible = False
      Me![lbl_name_select].Visible = True
   Else
      Me![TabCtl21].Visible = True
      Me![frm_Member_Appeal].Visible = True
      Me![frm_Letters].Visible = True
      Me![frm_PRC].Visible = True
      Me![lbl_name_select].Visible = False
   End If
End Sub

Private Sub cbo_Entered_By_Exit(Cancel As Integer)
    Call Form_Current   
End Sub

Hi,
I've been trying to get this to work, but it's not doing what I think it should be doing.

If it's a new record, and the cbo has not been selected yet. I want the sub forms to be hidden, but what is happening is they are always appearing when the main form loads.

Then what I want it to do is if this is not a new record, and something has already been selected in the cbo, then the subforms should be visible onload. So they can make changes if needed.

I've checked my name of the cbo and I have that correct, so it's not that. any ideas to what I could be doing wrong?
 
Last edited:
It looks like it should be working to me....are you sure you're not accidentally referring to the subform 'forms' themselves, instead of the subform container controls?

Maybe if you uploaded a stripped down, zipped version of your db that would help us diagnose it better.
 
I just created a new form, and inserted the same field names and tried the code and it worked?

So there is something on my real form that is stopping it from working. Not sure what.
So I'll need to troubleshoot and see what's conflicting with it.

I did notice on my test form, the after exit code would not work.
Not until, I went and actually click on the property screen the 'onexit' field, and selected the 'code builder' option, then just exited it out.

Did that, and it would work just fine. not sure why tho??
 
cool found the problem!

Not sure how this got set in my table, but the default value for the field that my combo box was bound to was set to 0.

So every new record was getting 0 put in that field (which I would change when I selected something from the list), so the code was working the whole time, just didn't notice it in the form because nothing was display in the combo box.
 
Well, glad you found it. One of those irritants of access is the default 0 in numeric fields that you have to change to null. I hear they've fixed that in ACCESS07....
 

Users who are viewing this thread

Back
Top Bottom