473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem with Memo field contents to String Variable

I am having problems trying to assign the contents of a Memo table
field to a String variable in VB using the following code:

Private Function udfBuildSQL(SQLID As Integer) As Variant

Dim rs As Recordset
Dim db As Database
Dim rSQL As String
Dim strSQL As String
Dim fld As Field
Dim fldLen As Long
Dim fldOffset As Long
Dim varChunk As Variant

Const cFldLen = 100
Set db = CurrentDb
rSQL = "SELECT * FROM tblSQL WHERE SQLID = " & SQLID

Set rs = db.OpenRecordset(rSQL)

Set fld = rs.Fields("SQLString")

fldLen = fld.FieldSize
fldOffset = 0

Do While fldOffset <= fldLen

varChunk = fld.GetChunk(fldOffset, cFldLen)
strSQL = strSQL & varChunk
fldOffset = fldOffset + Len(varChunk)
fldLen = fldLen - Len(varChunk)
If Len(varChunk) = 0 Then
Exit Do
Else: End If

Loop

udfBuildSQL = strSQL
End Function

Although the GetChunk retrieves the data correctly, the strSQL
variable doesn't take more than the first 250 or so characters. At
first I thought I might be hitting a similar limit to the 255
character maximum for a text table field, but have since confirmed
that this limit does not apply to string variables.

I have tried other methods to populate the strSQL variable, but it
still is limited to the first 250 or so characters.

Any suggestions or solutions would be greatly appreciated.

Thanks

Martin Heal
Nov 13 '05 #1
1 6046
I find
DLookup("SQLString","tblSQL ","SQLID=" & SQLID)
will return the full string, even for a memo field longer than 250
characters.

I'm using Access 2000 - what about you?
"Martin Heal" <mh***@bigfoot.com> wrote in message
news:80**************************@posting.google.c om...
I am having problems trying to assign the contents of a Memo table
field to a String variable in VB using the following code:

Private Function udfBuildSQL(SQLID As Integer) As Variant

Dim rs As Recordset
Dim db As Database
Dim rSQL As String
Dim strSQL As String
Dim fld As Field
Dim fldLen As Long
Dim fldOffset As Long
Dim varChunk As Variant

Const cFldLen = 100
Set db = CurrentDb
rSQL = "SELECT * FROM tblSQL WHERE SQLID = " & SQLID

Set rs = db.OpenRecordset(rSQL)

Set fld = rs.Fields("SQLString")

fldLen = fld.FieldSize
fldOffset = 0

Do While fldOffset <= fldLen

varChunk = fld.GetChunk(fldOffset, cFldLen)
strSQL = strSQL & varChunk
fldOffset = fldOffset + Len(varChunk)
fldLen = fldLen - Len(varChunk)
If Len(varChunk) = 0 Then
Exit Do
Else: End If

Loop

udfBuildSQL = strSQL
End Function

Although the GetChunk retrieves the data correctly, the strSQL
variable doesn't take more than the first 250 or so characters. At
first I thought I might be hitting a similar limit to the 255
character maximum for a text table field, but have since confirmed
that this limit does not apply to string variables.

I have tried other methods to populate the strSQL variable, but it
still is limited to the first 250 or so characters.

Any suggestions or solutions would be greatly appreciated.

Thanks

Martin Heal

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tim Pollard | last post by:
Hi I am trying to filter a table of users to select only those records whose roleID matches a value in an array. There could be any number of IDs held in the array from one to a few hundred. The...
6
by: Shyguy | last post by:
I want to create two buttons on a form. One would allow the user to Copy the contents of the current records memo field, the other would allow them to print. I set up a report based on the memo...
1
by: Steemer | last post by:
Okay, I checked with usual suspects and I'm still frustrated. ..txt file, fixed width. About 88 fields of varying length. All text fields. It will only let me add seperators to about the 410th...
2
by: Bob Dydd | last post by:
Hi Everybody I have a Listbox that has a Memo field attached to it's 2nd column which on double click copies the memo field to another Memo Field. Forms!! = ListClassification.Column(1) My...
3
by: John | last post by:
I have a field, data type Memo, in a job details table. I have a text box on a report which I need to print the contents of this field. My problem is that the text box will only display 255...
9
by: philip | last post by:
If I execute that : Dim Temp as string = "This is a text" Dim sw As StreamWriter Dim fullFileName as string = "c:\text.txt" sw = New StreamWriter(fullFilename) sw.Write(temp) sw.Close() ...
1
by: alexsg | last post by:
A little while ago Ron P kindly responded to my inquiry on how to copy the first line of memo field into a text field, using a query: left(,instr(1,,vbCrLf)-1) This is great, but I would like...
9
by: RMC | last post by:
Hello, I'm looking for a way to parse/format a memo field within a report. The Access 2000 database (application) has an equipment table that holds a memo field. Within the report, the memo...
15
by: sara | last post by:
I have a Memo field in a table to hold notes from a conversation a social worker has had with a client (this is for a non-profit). If the user needs to update the memo field, I need to find the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.