Use of the Boolean "Or" in expressions.

  • Thread starter Thread starter Frank Martin
  • Start date Start date
F

Frank Martin

I have several Combo Boxes on a form, each one to select a class of
address (Customer, Supplier, Personal etc.)

I have just bought a ticket printer ("Brother QL500") and this is connected
and working well.

I want the ticket printer to print labels from ANY category of address shown
above, that is when any of the relevant Combos is selected then a ticket
based on its 'AddessesID' can be printed.

I thought the simplest way to do this was to place an separate unbound
control on the form "Text164" and then use the expression builder to make
the Control Source:
=[Combo64] Or [Combo65] Or [Combo66] Or [Combo67]

But this doesn't work, and all I get is a "-1" in the Text164

Can someone help me here? Regards, Frank
 
Frank,

Is your labels report based on a query? If so, you can put the
equivalent of the following in the criteria of the AddressesID field in
the query...
[Forms]![NameOfForm]![Combo64] Or [Forms]![NameOfForm]![Combo65] Or
[Forms]![NameOfForm]![Combo66] Or [Forms]![NameOfForm]![Combo67]

Or, are you printing your label report via a Command Button Click event
procedure, or some other procedure on a form-based event. If so, you
might have something like...
DoCmd.OpenReport "YourLabels", , , "AddressesID =" & Nz(Me.Combo64,0)
& " Or AddressesID =" & Nz(Me.Combo65,0) & " Or AddressesID =" &
Nz(Me.Combo66,0) & " Or AddressesID =" & Nz(Me.Combo64,0)
 
Frank Martin said:
I have several Combo Boxes on a form, each one to select a class of
address (Customer, Supplier, Personal etc.)

I have just bought a ticket printer ("Brother QL500") and this is connected
and working well.

I want the ticket printer to print labels from ANY category of address shown
above, that is when any of the relevant Combos is selected then a ticket
based on its 'AddessesID' can be printed.

I thought the simplest way to do this was to place an separate unbound
control on the form "Text164" and then use the expression builder to make
the Control Source:
=[Combo64] Or [Combo65] Or [Combo66] Or [Combo67]

But this doesn't work, and all I get is a "-1" in the Text164

Can someone help me here? Regards, Frank

What is the Row Source for the combo boxes? I would be willing to bet that
there are at least 2 columns. The bound column (autonumber?) and the address
column (text). The expression you used for the unbound control ("Text164") is
displaying -1 (True) because one or more of the combo boxes has an entry
(look up logical "OR").

If the address is in the second column (remember - zero based), you could
try using ("&" not "OR"):

=Nz([Combo64].Column(1),"") & Nz([Combo65].Column(1),"") &
NZ([Combo66].Column(1),"") & Nz([Combo67].Column(1),"")

or maybe (air code):

=IIF(Len(Trim([Combo64].Column(1)>0,[Combo64].Column(1),IIF(Len(Trim([Combo65].Column(1)>0,[Combo65].Column(1),IIF(Len(Trim([Combo66].Column(1)>0,[Combo66].Column(1),IIF(Len(Trim([Combo67].Column(1)>0,[Combo67].Column(1),""))))


I don't understand why you have multiple combo boxes for addresses - unless
they are unbound. But even then...?? Do you have multiple fields for
addresses or a lookup table?

I would use an unbound combo box (or option group) to select "Customer,
Supplier, Personal, etc." and have code in the AfterUpdate event push the
address into the control "Text164".

Just my thoughts....

HTH
 
Yes I have the one "QryAddresses" for all addresses and the Combo-box
queries are filtered for a particular address class.

On my invoice form I have a nest of small tabbed forms each dedicated to an
address class, and the relevant tab is exposed automatically when a
particular addess Combo is used.

I have solved the problem by simply putting a command button (view report)
on each small tab form and using the following code to expose the address
lable:

***

Private Sub Command88_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "RptLABELLER"

'stLinkCriteria = "[AddressesID]=" & "'" & Me![AddressesID] & "'"
stLinkCriteria = "[AddressesID]=" & Me![AddressesID]

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
DoCmd.RunCommand acCmdZoom75
Exit_Command48_Click:
Exit Sub


End Sub
*****

I can then print out the little labels as required.

Thank you for your solution and I have filed it away for thr future.
Regards Frank


Steve Schapel said:
Frank,

Is your labels report based on a query? If so, you can put the equivalent
of the following in the criteria of the AddressesID field in the query...
[Forms]![NameOfForm]![Combo64] Or [Forms]![NameOfForm]![Combo65] Or
[Forms]![NameOfForm]![Combo66] Or [Forms]![NameOfForm]![Combo67]

Or, are you printing your label report via a Command Button Click event
procedure, or some other procedure on a form-based event. If so, you might
have something like...
DoCmd.OpenReport "YourLabels", , , "AddressesID =" & Nz(Me.Combo64,0) & "
Or AddressesID =" & Nz(Me.Combo65,0) & " Or AddressesID =" &
Nz(Me.Combo66,0) & " Or AddressesID =" & Nz(Me.Combo64,0)

--
Steve Schapel, Microsoft Access MVP

Frank said:
I have several Combo Boxes on a form, each one to select a class of
address (Customer, Supplier, Personal etc.)

I have just bought a ticket printer ("Brother QL500") and this is
connected
and working well.

I want the ticket printer to print labels from ANY category of address
shown
above, that is when any of the relevant Combos is selected then a ticket
based on its 'AddessesID' can be printed.

I thought the simplest way to do this was to place an separate unbound
control on the form "Text164" and then use the expression builder to make
the Control Source:
=[Combo64] Or [Combo65] Or [Combo66] Or [Combo67]

But this doesn't work, and all I get is a "-1" in the Text164

Can someone help me here? Regards, Frank
 
SteveS said:
Frank Martin said:
I have several Combo Boxes on a form, each one to select a class of
address (Customer, Supplier, Personal etc.)

I have just bought a ticket printer ("Brother QL500") and this is
connected
and working well.

I want the ticket printer to print labels from ANY category of address
shown
above, that is when any of the relevant Combos is selected then a ticket
based on its 'AddessesID' can be printed.

I thought the simplest way to do this was to place an separate unbound
control on the form "Text164" and then use the expression builder to make
the Control Source:
=[Combo64] Or [Combo65] Or [Combo66] Or [Combo67]

But this doesn't work, and all I get is a "-1" in the Text164

Can someone help me here? Regards, Frank

What is the Row Source for the combo boxes? I would be willing to bet that
there are at least 2 columns. The bound column (autonumber?) and the
address
column (text). The expression you used for the unbound control ("Text164")
is
displaying -1 (True) because one or more of the combo boxes has an entry
(look up logical "OR").

If the address is in the second column (remember - zero based), you could
try using ("&" not "OR"):

=Nz([Combo64].Column(1),"") & Nz([Combo65].Column(1),"") &
NZ([Combo66].Column(1),"") & Nz([Combo67].Column(1),"")

or maybe (air code):

=IIF(Len(Trim([Combo64].Column(1)>0,[Combo64].Column(1),IIF(Len(Trim([Combo65].Column(1)>0,[Combo65].Column(1),IIF(Len(Trim([Combo66].Column(1)>0,[Combo66].Column(1),IIF(Len(Trim([Combo67].Column(1)>0,[Combo67].Column(1),""))))


I don't understand why you have multiple combo boxes for addresses -
unless
they are unbound. But even then...?? Do you have multiple fields for
addresses or a lookup table?

I would use an unbound combo box (or option group) to select "Customer,
Supplier, Personal, etc." and have code in the AfterUpdate event push the
address into the control "Text164".

Just my thoughts....

HTH

I have just finished a long project to resolve all my separate address
tables into just one, and all addresses are now derived from the one query
based on this table.

I use the several Combo boxes on my invoice form to insert addesses into
address blocks on to the invoice, and I can optionally insert freighter
details, pickup details etc.

The Combo boxes are linked to tabbed forms via the fom/subform master/child
system and they work very well indeed.

Regards Frank
 
Back
Top