Produce HEX and ASCII in query results

dzirkelb

Registered User.
Local time
Today, 17:01
Joined
Jan 14, 2005
Messages
180
We have a need to produce hex and ascii in the same results field.

The field with data will be bound to a 2D barcode (the square ones you see everywhere now). The format of the data is to look like this:

[)><RS>06<GS>xyz<RS><EOT>

The <RS>, <GS>, and <EOT> all need to be hex values as follows:

<RS> = Hex 1E, Decimal 30
<GS> = Hex 1D, Decimal 29
<EOT> = Hex 04, Decimal 04

When I run my Access query as follows:

BarCode: "[)>"&Hex(30)&"06"&Hex(29)&"xyz"&Hex(30)&""&Hex(04)&""

It produces the following:

[)>1E061Dxyz1E04

So, it just converts it to ASCII; however, when I go to scan it, it actually reads that information also. I need the 1E, 1D, and 04 to actually be scanned as HEX for the validation to occur for our client.

Is it possible using an Access query to return these desired results? If not, I will have to look atother piece of software to produce the bar code labels.
 
When I run my Access query as follows:

BarCode: "[)>"&Hex(30)&"06"&Hex(29)&"xyz"&Hex(30)&""&Hex(04)&""

It produces the following:

[)>1E061Dxyz1E04

So, it just converts it to ASCII; however, when I go to scan it, it actually reads that information also. I need the 1E, 1D, and 04 to actually be scanned as HEX for the validation to occur for our client.
How do you want to result should be?
 
So, it just converts it to ASCII; however, when I go to scan it, it actually reads that information also. I need the 1E, 1D, and 04 to actually be scanned as HEX for the validation to occur for our client..

You are misunderstanding the terminology. They are Hexadecimal values.

You want actual binary values stored. Write to a file via a TextStreamObject in Binary mode. Then use an Attachment datatype field to store it in the database.
 
When you write hex, you have to write it in ascii, because you have to use ascii characters. Then, if you want to read it back as hex, you have to know which ascii characters represent hex and then you need to convert them. For instance, which of these are hex?
Code:
100
1EE
FFF
ABC
001
That's right, all of them, but how are you going to know if "100" is decimal or hex or octal or binary? And what if your data is not "xyz" but "1E04" instead. How is your parser going to know that is your data, not hex?

See what I'm saying? Once you've written it out to a string, it's all ascii. The fact of it being hexadecimal is lost information. Same with binary. If you write the binary number 3, that's 11. Now, when you read that back in, it's 11, unless your read the ascii and convert it back to binary.
 
For my application I need to assign that string / binary mix to a bar code. I can do this via the program BarTender, but we don't own that program.

Is there a simpler solution besides outputing the string / binary combo to a text file, then linking it to a data field for a query? If I am unable to do it in one or two lines of code in VB or in an access query direct, then I will just dump this project and purchase Bartender.

For reference, all of the binary portions of the data will be static, where most of the string data will be pulled from a database.
 
You don't need to write to a binary file if you write ascii, read ascii, and do whatever conversions you need to do.
 

Users who are viewing this thread

Back
Top Bottom