making forms visible and not visible

S

short

I am having issues trying to figure this out and I'm hoping someone here can
help.
I have four forms that are all based off of a query. One is software, basic
information about the software while the other three are the complete
information about that software. I'll call them softwareA, softwareB,
softwareC.

What I want to be able to do is in software there is a entry called name,
where the user types in any of the three software names. I want that form to
come up. Now, I did it where the tables were all visible and then would come
up when the user types it in. But once the user is finished and wants to type
in a new software information, that softwarA etc.. table does not disappear.

Here's the code I have:

Private Sub Software_Name_AfterUpdate()
'These will only open the form that is needed. S/as softwareA when the user
types in the choice

If Software_Name.Text = "SoftwareA" Then
Me.SoftwareAForm.Visible = True
ElseIf Software_Name.Text = "SoftwareB" Then
Me.SoftwareBForm.Visible = True
ElseIf Software_Name.Text = "SoftwareC" Then
Me.SoftwareCForm.Visible = True
Else
Me.SoftwareAForm.Visible = False
Me.SoftwareBForm.Visible = False
Me.SoftwareCForm.Visible = False
End If
End Sub

Is there a way to clear these forms back to not visible? or should I do pop
ups?

Thanks
 
B

BruceM

Are SoftwareAForm, SoftwardBForm, etc. subform controls on the form? If
they are standalone forms I can't see how the code would compile, let alone
run.

Is there a reason you are using the Text property rather than the default
Value property for the text box? Also, why leave off the Me for just that
control? You may do better to use:
If Me.Software_Name = etc.
for the sake of consistency if nothing else.

That being said, here is the logic problem: As long as SoftwareName is
"SoftwareA", "SoftwareB", or "SoftwareC" the code will not reach the Else,
so any previously visible control will remain visible.

Maybe something like this would do the trick:

Select Case Me.Software_Name
Case "SoftwareA"
Me.SoftwareAForm.Visible = True
Me.SoftwareBForm.Visible = False
Me.SoftwareCForm.Visible = False
Case "SoftwareB"
Me.SoftwareAForm.Visible = False
Me.SoftwareBForm.Visible = True
Me.SoftwareCForm.Visible = False
Case "SoftwareC"
Me.SoftwareAForm.Visible = False
Me.SoftwareBForm.Visible = False
Me.SoftwareCForm.Visible = True
Case Else
Me.SoftwareAForm.Visible = False
Me.SoftwareBForm.Visible = False
Me.SoftwareCForm.Visible = False
End Select
 
S

short

Yes each softwareAform are subform controls on the form, so I don't know if
that would change anything said below.
I'm still learning everything in access so what is default value property
for the text box?
 
B

BruceM

In order to use the Text property the control needs to have the focus.
There are limited reasons for using the Text property, but I don't think
your situation is one of those reasons. In most cases you want to use:
Me.Software_Name.Value
or just
Me.Software_Name

By "default property" I meant that if you do not specify Value, Access
assumes you mean the Value property (that is, the contents of the text box).

The code should work as I have written it. Give it a try. See Help for
more information about Select Case.
 

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