problem writing text to textbox

P

PayeDoc

Hello All

I have a procedure that builds an xml file and then sends it to a 3rd
party - a government online server. The final part of the process is when an
acknowledgement is received from the government online server: this is
returned by the procedure as 'ResponseText', which I then need to write to
the texbox 'txtServerResponse' on the current form. I was expecting to be
able to do this very simply with

txtServerResponse.Text = ResponseText

.... but for some reason I keep getting runtime error 2176 and a message that
"The setting for this property is too long", and clicking debug takes me to
the line

txtServerResponse.Text = ResponseText

I have checked the properties of the textbox 'txtServerResponse', and can
see no restriction that should cause the problem. Initially,
txtServerResponse was bound to a memo field from the form's underlying
table, but in fact I have also tried replacing it with an unbound textbox,
but this made no difference. I know that txtServerResponse is able to accept
the value of 'ResponseText', because when I add

Debug.Print ResponseText

to the procedure, then do ctrl-G and copy the text I can paste it into
'txtServerResponse' without a problem. I have found that I can even use

Call ClipBoard_SetData(ResponseText)

to put 'ResponseText' directly onto the clipboard, from were I can paste it
into 'txtServerResponse'.

The end of the procuedure is currently as follows:

Private Sub mcls2P45_ServerResponse(ResponseText As String)
txtServerResponse.SetFocus
txtServerResponse.Text = ""
txtServerResponse.Text = ResponseText
Debug.Print ResponseText
Call ClipBoard_SetData(ResponseText)
End Sub

.... but I can only get past the line txtServerResponse.Text = ResponseText
by commenting it out.

If anyone can suggest a likely cause for this I would be very grateful. As a
(hopefully short-term) workaround, does anyone know the 'paste' equivalent
to Call ClipBoard_SetData(ResponseText), so that I could get the value of
'ResponseText ' into 'txtServerResponse' that way?

Many thanks for any help.
Leslie Isaacs
 
L

Linq Adams via AccessMonster.com

Error messages in Access are often inaccurate and don't always pint to the
exact problem.

The first thing I noticed was the use of the Text property, which is used in
straight Visual Basic but seldom in Access VBA, because in Access, in order
to work, the control has to have focus. Try replacing all of your lines such
as

txtServerResponse.Text

with

txtServerResponse.Value

or, more simply,

txtServerResponse

since Value is the default property and can be omitted.

This is assuming, of course, that the length of the field behind
txtServerResponse is, in fact, big enough to accept the response.
 
P

PayeDoc

Hello Linq

Very many thanks for your reply: removing the .text has done it!

Thanks again
Les
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top