VBA Userform (1 Viewer)

iseman22

Registered User.
Local time
Today, 17:19
Joined
May 1, 2012
Messages
16
2010 Access VBA newb on a network. I have a couple of fields that I want hidden until user checks the controlbox. Found a soultion that requires a userform. Trying to insert a userform in VBA; however, it's not available on the insert menu.

Is it possible our network admin has blocked userforms?

Is there another method for hidding fields until a controlbox is checked?

Thanks in advance for helping an old DB author learn new tricks. :eek:
 

pr2-eugin

Super Moderator
Local time
Today, 22:19
Joined
Nov 30, 2011
Messages
8,494
Hello iseman22, welcome aboard. It is not possible to insert a Form in VBA.
Forms are designed/created in the Access DB which acts like the UserInterface and the coding is what you do in the background to help add/edit data in tables.

Do you have a Form that has a controlbox?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 22:19
Joined
Sep 12, 2006
Messages
15,710
simply code these

in the afterupdate event box for the checkbox

mycontrol1.visible = mycheckbox=true
mycontrol2.visible = mycheckbox=true

you probably need these in the form's current event also
 

iseman22

Registered User.
Local time
Today, 17:19
Joined
May 1, 2012
Messages
16
Thanks for the quick response, Dave!

I used the code below:

Private Sub StopSplit_Change()
Select Case StopSplit
Case "2"
Me.Label48.Visible = True
Me.DODAAC2.Visible = True
Me.Label45.Visible = True
Me.Text44.Visible = True
Me.Label47.Visible = True
Me.Text46.Visible = True
Case "3"
Me.Label48.Visible = True
Me.DODAAC2.Visible = True
Me.Label45.Visible = True
Me.Text44.Visible = True
Me.Label47.Visible = True
Me.Text46.Visible = True
Me.Label54.Visible = True
Me.DODAAC3.Visible = True
Me.Label51.Visible = True
Me.Text50.Visible = True
Me.Label53.Visible = True
Me.Text52.Visible = True
Case "4"
Me.Label48.Visible = True
Me.DODAAC2.Visible = True
Me.Label45.Visible = True
Me.Text44.Visible = True
Me.Label47.Visible = True
Me.Text46.Visible = True
Me.Label54.Visible = True
Me.DODAAC3.Visible = True
Me.Label51.Visible = True
Me.Text50.Visible = True
Me.Label53.Visible = True
Me.Text52.Visible = True
Me.Label60.Visible = True
Me.DODAAC4.Visible = True
Me.Label57.Visible = True
Me.Text56.Visible = True
Me.Label59.Visible = True
Me.Text58.Visible = True
Case Else
Me.DODAAC2.Visible = False
Me.DODAAC3.Visible = False
Me.DODAAC4.Visible = False
End Select
End Sub

I'm trying to get form fields DODAAC2, 3, and 4 (and the unbound text boxes and corresponding labels which display information about the data entered in the DODAAC field{s}) to unhide when my user enters 2, 3 or 4 in my controlbox (StopSplit).

Unfortunately, when I run the code, I get an compile error: method or data member not found.

Nothing like diving into the deep end of the pool not knowing how to swim ;)

I think it might be easier to learn VBA and Access if I could just wipe my memory of old-DB writing days.
 

ghudson

Registered User.
Local time
Today, 17:19
Joined
Jun 8, 2002
Messages
6,195
If the lines in red are your errors then it is odd that the only objects you have named is causing the problem. You need to rename your objects (labels, text boxes, etc) with something meaningfull and give them a prefix that identifies what it is. text box = txtTextBoxName, label = lblLabelName, etc.

Is the data type for the StopSplit numeric or text? Only text needs to be enclosed in apostrophes. Case 2 not Case "2"
 

iseman22

Registered User.
Local time
Today, 17:19
Joined
May 1, 2012
Messages
16
Thanks Ghudson. Your advice:

"You need to rename your objects (labels, text boxes, etc) with something meaningfull and give them a prefix that identifies what it is. text box = txtTextBoxName, label = lblLabelName, etc..."

was spot on! While I copied DODAAC2, 3, and 4, I forgot to change the field name. What a newb!!

Problem solved. Thanks All!!
 

Users who are viewing this thread

Top Bottom