
Truncation Issue w/ Strings
Hello,
I just had a similar problem today with this type of thing, I posted the
question into the microsoft.public.access newsgroup along with the solution
I arrived at.
Essentially what I found was that access was returning the field as a
Text(255) field, and so it was truncating the string at 255. The weird
thing was that the in ado, when I read the value of the field, it would
return a string of the correct length, with the first 255 bytes containing
data from the table, and the rest seemed to be reading memory from other
processes, I could see environment information, system stuff, etc.. very
odd.
I was getting the results from an access query, so I ended up having to
create a temp table, and insert the rows into a memo field in the temp
table, then I could read from it... Very bazaar.
Delow is the text from my message in the other group in case it helps.
Ok, I found a work around, I don't know how great it is, but oh well..
Anyway, if anyone is interested, here it is:
In VBA code:
1. open a recordset from the query
2. Create a temp table
3. append the fields from the query into the temp table. If the recordset
field is text, change it to memo in the temp table.
4. execute the query as an insert into query into the temp table.
5. select from the temp table.
voila the values don't get truncated
--
Support Fairtax Legislation
www.fairtax.org
"A government big enough to give you everything you want, is strong enough
to take everything you have."
-Thomas Jefferson
Quote:
> Hi,
> I have a problem with an access DB app. It seems pretty straightforward,
> but it is giving me all kinds of grief.
> I have a query that calls a function to get a list of descriptions ie:
> I can reproduce the behavior very easily by creating a module, and adding
> the following:
> Function getList() As String
> getList = "fdsjaklfh shfd slhfjdlsh jfdaj fdhsjflhsjflhjd sahfjdsha
> jfdhsjf hdsafhdsj fhjdshfjdsajsdk fhsdhfjdshf jsdhfjshjf hdsjfhjsdahfjsda
> h " & _
> "fdhsjak hfdjksh fdshfjkdlsh fjdshfj hdslfh dshfjlshjfhdsjflhdsjlfh
> dsjlkhfjdshfjdha jfdhj f " & _
> "fdhsjak hfdjksh fdshfjkdlsh fjdshfj hdslfh dshfjlshjfhdsjflhdsjlfh
> dsjlkhfjdshfjdha jfdhj f " & _
> "fdhsjak hfdjksh fdshfjkdlsh fjdshfj hdslfh dshfjlshjfhdsjflhdsjlfh
> dsjlkhfjdshfjdha jfdhj the end "
> End Function
> Sub test()
> Dim rs As Recordset2
> Set rs = CurrentDb.OpenRecordset("Select * from query1")
> debug.print rs("Expr1")
> End Sub
> Then create query1 as the following:
> SELECT getList() AS Expr1;
> you will see that it shows the first few characters (I think it's 255, but
> I haven't actually counted), but then just a bunch of garbage after that.
> If I open query1 in the access front end, it works just fine, but I can't
> get at the data from within the code. Is there a trick I am not aware of
> to do this?