Visible Control Source based on Combo Selection

J

Johnny

This should be fairly simple, but would someone assist to see what I am
missing on this. I have a combo based on a value list of 3 asset options:
PC, Printer, Other. If the form shows PC on the combo I want the computer's
machine name to be visible, but not visible if the form shows the other two
options in the combo. Fairly basic. Device type is the name of my combo.
Here is my code on the on open properties:

Private Sub Form_Open(Cancel As Integer)
If [Device type] = "PC" Then
[Machine Name].Visible = True
Else
[Machine Name].Visible = False
End If
End Sub

I also have the machine name control set to visible "no".

I'm a simpleton at coding and have spent the afternoon trying to make this
work and reading other similar posts. Any suggestions is greatly appreciated.

Thanks in advance.
 
J

Johnny

Sorry if I bothered anyone. I just needed to have this loaded "on Current"
and not "on Open". Thanks to anyone who checked out my question.
 
P

PJFry

The first thing to do is to check out the actual value of the combo box.
Check the properties, Format, Column Count. My guess is that you may have a
hidden column and the if statement does not know which column to evaluate.

Try that and let me know what you get.

PJ
Johnny said:
Sorry if I bothered anyone. I just needed to have this loaded "on Current"
and not "on Open". Thanks to anyone who checked out my question.
--
Johnny


Johnny said:
This should be fairly simple, but would someone assist to see what I am
missing on this. I have a combo based on a value list of 3 asset options:
PC, Printer, Other. If the form shows PC on the combo I want the computer's
machine name to be visible, but not visible if the form shows the other two
options in the combo. Fairly basic. Device type is the name of my combo.
Here is my code on the on open properties:

Private Sub Form_Open(Cancel As Integer)
If [Device type] = "PC" Then
[Machine Name].Visible = True
Else
[Machine Name].Visible = False
End If
End Sub

I also have the machine name control set to visible "no".

I'm a simpleton at coding and have spent the afternoon trying to make this
work and reading other similar posts. Any suggestions is greatly appreciated.

Thanks in advance.
 
J

Johnny

PJFry,

Thank you for checking out my post, but I'm not honestly sure what you are
saying. As far as I can tell the combo is set to only one column count. I
thought I had this figured out yesterday by making my code work "on current"
instead of "on Open", and it did work on the Machine Name control just fine.
Now they have thrown a loophole in the mix and added the combo to not only be
PC, PRINTERS and OTHER, but now they want to add LAPTOP and SERVER and have
it do the same thing for PC where the machine name is not visible unless PC
or LAPTOP or SERVER is selected. I tried this, but it did not work:
Private Sub Form_Current()
If [Device type] = "PC" & _
Or [Device type] = "Server" & _
Or [Device Type] = "Laptop" Then
[Machine Name].Visible = True
Else
[Machine Name].Visible = False
End If

End Sub

Suggestions? Thank you.
--
Johnny


PJFry said:
The first thing to do is to check out the actual value of the combo box.
Check the properties, Format, Column Count. My guess is that you may have a
hidden column and the if statement does not know which column to evaluate.

Try that and let me know what you get.

PJ
Johnny said:
Sorry if I bothered anyone. I just needed to have this loaded "on Current"
and not "on Open". Thanks to anyone who checked out my question.
--
Johnny


Johnny said:
This should be fairly simple, but would someone assist to see what I am
missing on this. I have a combo based on a value list of 3 asset options:
PC, Printer, Other. If the form shows PC on the combo I want the computer's
machine name to be visible, but not visible if the form shows the other two
options in the combo. Fairly basic. Device type is the name of my combo.
Here is my code on the on open properties:

Private Sub Form_Open(Cancel As Integer)
If [Device type] = "PC" Then
[Machine Name].Visible = True
Else
[Machine Name].Visible = False
End If
End Sub

I also have the machine name control set to visible "no".

I'm a simpleton at coding and have spent the afternoon trying to make this
work and reading other similar posts. Any suggestions is greatly appreciated.

Thanks in advance.
 

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