Textbox length

  • Thread starter Thread starter Leonard McKeown
  • Start date Start date
L

Leonard McKeown

Hi, I'm a teacher trying to join comments.
I'd appreciate your help.

I have a field called "comment" defined as a 'memo' in a
table.

I have a textbox on a form and a command button.

When you press the command button, vba joins all the other
comments into one comment and displays this in the textbox.

All worked fine.

However, now I am getting a "Run time error 2167 - the
setting for this property is too long"

I did a count on the characters in the textbox and it's at
1827.

Help.

Leonard
 
Leonard McKeown said:
Hi, I'm a teacher trying to join comments.
I'd appreciate your help.

I have a field called "comment" defined as a 'memo' in a
table.

I have a textbox on a form and a command button.

When you press the command button, vba joins all the other
comments into one comment and displays this in the textbox.

All worked fine.

However, now I am getting a "Run time error 2167 - the
setting for this property is too long"

I did a count on the characters in the textbox and it's at
1827.

Help.

Leonard

Hi, Leonard! Please post the code behind the command button. If you
can, indicate on which line of the code the error is being raised.
 
-----Original Message-----


Hi, Leonard! Please post the code behind the command button. If you
can, indicate on which line of the code the error is being raised.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Thanks Dirk

Here's the code.

The error is happening on the second last line:
DWCom.text = GoodText

The sub changetext is a routine to change proper nouns to
the student's own name and his/her etc...

-------------------------------------------------------


Private Sub UpDateWriting_Click()

Dim DWExtraC As String
Dim DWNotesC As String
Dim DWComC As String

Dim DWWillC As Integer
Dim DWProc As Integer
Dim DWEditC As Integer
Dim DWProofC As Integer
Dim DWGenreC As Integer
Dim DWSentC As Integer
Dim DWVocabC As Integer
Dim DWPuncC As Integer
Dim DWSpellC As Integer
Dim DWGenFeaC As Integer

Dim Text1 As String
Dim Text2 As String
Dim Text3 As String
Dim Text4 As String
Dim Text5 As String
Dim Text6 As String
Dim Text7 As String
Dim Text8 As String
Dim Text9 As String
Dim Text10 As String
Dim Text11 As String
Dim Text12 As String
Dim Text13 As String

Dim rawtext As String

DWWill.SetFocus
DWWillC = DWWill

DWPro.SetFocus
DWProc = DWPro

DWEdit.SetFocus
DWEditC = DWEdit

DWProof.SetFocus
DWProofC = DWProof

DWGenre.SetFocus
DWGenreC = DWGenre

DWSent.SetFocus
DWSentC = DWSent

DWVocab.SetFocus
DWVocabC = DWVocab

DWPunc.SetFocus
DWPuncC = DWPunc

DWSpell.SetFocus
DWSpellC = DWSpell

DWGenFea.SetFocus
DWGenFeaC = DWGenFea


Text1 = "During Daily Writing,"

Text2 = DLookup("DWWillCom", "DWWilling", "[DWWill] =" &
DWWillC)

' first is comment
' second is name of table
' third is reference, in this case and usually the key
field


Text3 = DLookup("DWProCom", "DWPro", "[DWpro] =" & DWProc)

Text4 = DLookup("DWEditCom", "DWEdit", "[DWEdit] =" &
DWEditC)

Text5 = DLookup("DWProofCom", "DWProof", "[DWProof] =" &
DWProofC)

Text6 = DLookup("DWGenreCom", "DWGenre", "[DWGenre] =" &
DWGenreC)

Text7 = vbCrLf & vbCrLf & "When analysing xstudent's
mechanics of writing, "

Text8 = Text7 & DLookup("DWSentCom", "DWSent", "[DWSent]
=" & DWSentC)

Text9 = DLookup("DWVocabCom", "DWVocab", "[DWVocab] =" &
DWVocabC)

Text10 = DLookup("DWPuncCom", "DWPunc", "[DWPunc] =" &
DWPuncC)

Text11 = DLookup("DWSpellCom", "DWSpell", "[DWSpell] =" &
DWSpellC)

Text12 = DLookup("DWGenFeaCom", "DWGenFea", "[DWGenFea] ="
& DWGenFeaC)

rawtext = Text1 & " " & Text2 & " " & Text3 & " " & Text4
& " " & Text5 & " " & Text6 & vbCrLf & Text8 & " " & Text9
& " " & Text10 & " " & Text11 & " " & Text12


Call ChangeText(rawtext)

DWCom.SetFocus
DWCom.text = GoodText

End Sub
 
Leonard McKeown said:
-----Original Message-----


Hi, Leonard! Please post the code behind the command button. If you
can, indicate on which line of the code the error is being raised.


Thanks Dirk

Here's the code.

The error is happening on the second last line:
DWCom.text = GoodText

The sub changetext is a routine to change proper nouns to
the student's own name and his/her etc...

-------------------------------------------------------


Private Sub UpDateWriting_Click()

Dim DWExtraC As String
Dim DWNotesC As String
Dim DWComC As String

Dim DWWillC As Integer
Dim DWProc As Integer
Dim DWEditC As Integer
Dim DWProofC As Integer
Dim DWGenreC As Integer
Dim DWSentC As Integer
Dim DWVocabC As Integer
Dim DWPuncC As Integer
Dim DWSpellC As Integer
Dim DWGenFeaC As Integer

Dim Text1 As String
Dim Text2 As String
Dim Text3 As String
Dim Text4 As String
Dim Text5 As String
Dim Text6 As String
Dim Text7 As String
Dim Text8 As String
Dim Text9 As String
Dim Text10 As String
Dim Text11 As String
Dim Text12 As String
Dim Text13 As String

Dim rawtext As String

DWWill.SetFocus
DWWillC = DWWill

DWPro.SetFocus
DWProc = DWPro

DWEdit.SetFocus
DWEditC = DWEdit

DWProof.SetFocus
DWProofC = DWProof

DWGenre.SetFocus
DWGenreC = DWGenre

DWSent.SetFocus
DWSentC = DWSent

DWVocab.SetFocus
DWVocabC = DWVocab

DWPunc.SetFocus
DWPuncC = DWPunc

DWSpell.SetFocus
DWSpellC = DWSpell

DWGenFea.SetFocus
DWGenFeaC = DWGenFea


Text1 = "During Daily Writing,"

Text2 = DLookup("DWWillCom", "DWWilling", "[DWWill] =" &
DWWillC)

' first is comment
' second is name of table
' third is reference, in this case and usually the key
field


Text3 = DLookup("DWProCom", "DWPro", "[DWpro] =" & DWProc)

Text4 = DLookup("DWEditCom", "DWEdit", "[DWEdit] =" &
DWEditC)

Text5 = DLookup("DWProofCom", "DWProof", "[DWProof] =" &
DWProofC)

Text6 = DLookup("DWGenreCom", "DWGenre", "[DWGenre] =" &
DWGenreC)

Text7 = vbCrLf & vbCrLf & "When analysing xstudent's
mechanics of writing, "

Text8 = Text7 & DLookup("DWSentCom", "DWSent", "[DWSent]
=" & DWSentC)

Text9 = DLookup("DWVocabCom", "DWVocab", "[DWVocab] =" &
DWVocabC)

Text10 = DLookup("DWPuncCom", "DWPunc", "[DWPunc] =" &
DWPuncC)

Text11 = DLookup("DWSpellCom", "DWSpell", "[DWSpell] =" &
DWSpellC)

Text12 = DLookup("DWGenFeaCom", "DWGenFea", "[DWGenFea] ="
& DWGenFeaC)

rawtext = Text1 & " " & Text2 & " " & Text3 & " " & Text4
& " " & Text5 & " " & Text6 & vbCrLf & Text8 & " " & Text9
& " " & Text10 & " " & Text11 & " " & Text12


Call ChangeText(rawtext)

DWCom.SetFocus
DWCom.text = GoodText

End Sub

First off, though this isn't the source of your problem, you appear to
be a whole bunch of "SetFocusing" to no purpose. An Access control
doesn't need to have the focus in order for you to read or change its
value, so code like this:
DWWill.SetFocus
DWWillC = DWWill
[...]
Text2 = DLookup("DWWillCom", "DWWilling", "[DWWill] =" &
DWWillC)

can be simplified to this:

Text2 = DLookup("DWWillCom", "DWWilling", "[DWWill] =" & DWWill)

As you can see your code could be a lot shorter.

I believe your problem comes from your use of the .Text property when
trying to set the value of the control DWCom:
DWCom.SetFocus
DWCom.text = GoodText

Unlike the Visual Basic text box, the default property of an Access text
box is the .Value property, and this is the property you should use when
trying to set the control's value. Although an Access text box does
have a .Text property, and the control must have the focus in order to
manipulate that property, that property has a specialized purpose and
is not really the property you should be using here. Replace the above
two line with this one:

DWCom = GoodText

and, provided GoodText is declared somewhere I don't see and has
(presumably) been set appropriately by the ChangeText() procedure, all
should be well.
 
Back
Top