Combo Box type mismatch

J

JIM

I'm getting a type mismatch 13 on this first if line and have tried several
things but can't see what is missing. The test is to see if first column of
combo box equals Name1 or Name2 then made controls not visible. CustomerName
is a text string.

If Left(Me.cboCustomerName.Column(0), 5) = "Name1" Or "Name2" Then

frmWorkOrders.sfrmClientBuildings.frmClientBuildings.txtRoofPlanLoc.Visible =
False
frmWorkOrders.sfrmClientBuildings.frmClientBuildings.Option60.Visible =
False

frmWorkOrders.sfrmClientBuildings.frmClientBuildings.RoofPlanLoc_Label.Visible = False
frmWorkOrders.sfrmClientBuildings.frmClientBuildings.Label64.Visible =
False
else if ....

Does anyone have an answer?
Thanks
 
M

Marshall Barton

JIM said:
I'm getting a type mismatch 13 on this first if line and have tried several
things but can't see what is missing. The test is to see if first column of
combo box equals Name1 or Name2 then made controls not visible. CustomerName
is a text string.

If Left(Me.cboCustomerName.Column(0), 5) = "Name1" Or "Name2" Then

frmWorkOrders.sfrmClientBuildings.frmClientBuildings.txtRoofPlanLoc.Visible =
False
frmWorkOrders.sfrmClientBuildings.frmClientBuildings.Option60.Visible =
False

frmWorkOrders.sfrmClientBuildings.frmClientBuildings.RoofPlanLoc_Label.Visible = False
frmWorkOrders.sfrmClientBuildings.frmClientBuildings.Label64.Visible =
False
else if ....

If Left(Me.cboCustomerName.Column(0), 5) = "Name1" _
Or Left(Me.cboCustomerName.Column(0), 5) = "Name2" Then
 
J

JIM

Thank you Marshall. Vb is as structured as RPG was - it drives me crazy! I
loved Pascal and Basic, but with VB every jot and tittle has to be in place.
I appreciate your answer and this forum.
God Bless
 
J

JIM

For those interested, using A2K this is final format of subroutine:
If Left(Me.cboCustomerName.Column(0), 5) = "Name1" Or
Left(Me.cboCustomerName.Column(0), 5) = "Name2" Then
Me.sfrmClientBuildings.Form.txtRoofPlanLoc.Visible = False
Me.sfrmClientBuildings.Form.Option60.Visible = False
Me.sfrmClientBuildings.Form.txtPrintAll.Visible = True
Me.sfrmClientBuildings.Form.Option62.Visible = True
Else
Me.sfrmClientBuildings.Form.txtRoofPlanLoc.Visible = True
Me.sfrmClientBuildings.Form.Option60.Visible = True
Me.sfrmClientBuildings.Form.txtPrintAll.Visible = False
Me.sfrmClientBuildings.Form.Option62.Visible = False
End If
This works perfect for me.
Regards.
 
M

Marshall Barton

JIM said:
For those interested, using A2K this is final format of subroutine:
If Left(Me.cboCustomerName.Column(0), 5) = "Name1" Or
Left(Me.cboCustomerName.Column(0), 5) = "Name2" Then
Me.sfrmClientBuildings.Form.txtRoofPlanLoc.Visible = False
Me.sfrmClientBuildings.Form.Option60.Visible = False
Me.sfrmClientBuildings.Form.txtPrintAll.Visible = True
Me.sfrmClientBuildings.Form.Option62.Visible = True
Else
Me.sfrmClientBuildings.Form.txtRoofPlanLoc.Visible = True
Me.sfrmClientBuildings.Form.Option60.Visible = True
Me.sfrmClientBuildings.Form.txtPrintAll.Visible = False
Me.sfrmClientBuildings.Form.Option62.Visible = False
End If


Not really important, but that could also be written:

Dim Name1or2 As Boolean
Name1or2 = Left(Me.cboCustomerName.Column(0), 5)="Name1" _
Or Left(Me.cboCustomerName.Column(0), 5)="Name2"
With Me.sfrmClientBuildings.Form
.txtRoofPlanLoc.Visible = Not Name1or2
.Option60.Visible = Not Name1or2
.txtPrintAll.Visible = Name1or2
.Option62.Visible = Name1or2
End With
 

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