Click to See Complete Forum and Search --> : MS Access - How to store various data types in the same field.


Ron Weller
05-11-2007, 07:29 PM
Is there a way to store text, numeric, and binary data (like from a file) into the same field.?
Normally If I wanted to store a Jpeg file into a field I would use the ADO Streams object to load the data into an OLE Object Field. But now I need to be able to store any kind data. Record 1 might contain Text data in that field where record two would contain an integer value. Record 3 might have a floating point value stored there, and record 4 might have an mp3 file stored there. I have other fields on the record that tell me what kind of data is stored and what size in bytes etc.
What I don't know is how to store each different kind of data into the field. This table is only used in code. There is no direct user interface, so I can use code to do all of the store and retreive functions.

Thank's in advance for any help or suggestions!
ron

Phil Weber
05-12-2007, 01:44 PM
I would use a Memo field and AppendChunk: http://support.microsoft.com/default.aspx/kb/194975

Ron Weller
05-12-2007, 04:11 PM
Very Cool!
- Any reason why Memo vs. OLE Object?
- When I am looking at my database structure I typically use Memo for large Text Items, and consider them viewable fields.
- But Ole Object's are inheariantly binary and therefore would not be directly viewable. In this case my data could be either, would it not be better to use the binary version, so access does not even try to display the contents?
- Viewing this data directly would only be a problem if you opend the table directly from within access, or even a query that selected the field. But still Access is smart enough not to try and display binary data, but using Memo it wouldn't know that the data was binary.

Thank's Phil

Ron