Form report - IF statement query

john141

New member
Local time
Today, 16:58
Joined
Nov 19, 2021
Messages
7
I have created a form called ProductLabels. This form is filled out and it produces the following report which is printed as a label.

1637333400893.png


The part in question is the Serial / Batch. This line is :

Code:
=Trim([Forms].[Frm_ProductLabels].[part_no]) & "/" & [Forms].[Frm_ProductLabels].[Text16]

part_no = part number pulled from the below query of my database table. Text16 is a textbox on the form, where the user enters the serial number.

1637333600563.png
1637333718127.png


On the report label, it is then printed as "part_no / serial no"

This works great, however not all equipment have a part number. This means when there is no part number it just displays as "/ serial number". What i would like to do is in this case, take away the / and have the serial number by itself.

How could i go about doing this? I was thinking of having an IF statement in my query saying IF part_no is not null then "part_no /" else "blank".

I am not sure how to produce this though, any help would be great
 

Attachments

  • 1637333692366.png
    1637333692366.png
    1.2 KB · Views: 360
Try

=(Trim([Forms].[Frm_ProductLabels].[part_no]) + "/") & [Forms].[Frm_ProductLabels].[Text16]
That works perfectly, had no idea it would be that simple! Makes sense now I am looking at it though

Thank you :)
 
Happy to help! It takes advantage of the fact that + will propagate Null and & will not.
 
Trim() is excess there. if part number is not blank, any leading space will be automatically removed
by msa.
 
Trim() is excess there. if part number is not blank, any leading space will be automatically removed
by msa.
Isn't it for trailing spaces as well?

Code:
tt="Paul   "
? tt
Paul   
? len(tt)
 7 
? len(tt + "/")
 8 
? len(trim(tt) + "/")
 5
 
correction on post#5, its trailing space (not leading).
part_no is a Field in the table.
try adding trailing space to the field, access will remove them.
 

Users who are viewing this thread

Back
Top Bottom