Text Box: Data cannot be saved.

K

Keith Willcocks

I wish to insert the contents of a field into a text box and display it.
The field in every case is a text string of a dozen or so characters. I am
using DAO 3.6 to run my database. It is written using MS Access 2002.

I have the code:

textbox1.setfocus
textbox1.text = RecordSetName!fieldname

This code is working perfectly throughout another application but on this
occasion I get this error message for all the text boxes involved:

"Run-time error '2115'
The macro or function set to the BeforeUpdate or ValidationRule
property for this field is preventing Microsoft Access from saving the
data in the field."

In fact both of these items in the text box properties are empty and despite
the message the data appears in the textbox but obviously the application
ceases to run. Comparing the textbox properties with those in the
application that work I can find no differences other than a change of font
specifications.

Can anyone advise as to what may be causing this problem please?
 
J

Jeanette Cunningham

Hi Keith,
post back all the code you have for the BeforeUpdate event for this field
and any other code you might have for any other events for this field.

Jeanette Cunningham
 
K

Keith Willcocks

That's what puzzles me. I have not got any BeforeUpdate events, or any
other events, for this or any of the text boxes but the same thing happens
for all of them. If I comment out the first one then the same problem
manifests itself with the second and so on.

Sorry to sound negative but I am really baffled by this.
 
K

Keith Willcocks

I have found a way to make it work OK but, for the life of me, I cannot
fathom why. Anyway, for anyone else with the same problem, this is what
fixed it. I simply removed .Text from the code so the sample I gave
became:

textbox1.setfocus
textbox1 = RecordSetName!fieldname

instead of:

textbox1.setfocus
textbox1.Text = RecordSetName!fieldname

Why that should make a difference I have no idea, especially as in the
previous application it worked fine with the.Text in place.

Can anyone come up with an explanation? Please!!
 
J

Jeanette Cunningham

Hi Keith,
glad you got it working. Sounds like you are using an unbound form.
The code textbox1 = RecordSetName!fieldname is usually the correct way to
code it.
The problem arises when you are trying to code the before update event for
the textbox in question, then you need to use textbox1.text which will give
the value of the entry in textbox1.

Jeanette Cunningham



Keith Willcocks said:
I have found a way to make it work OK but, for the life of me, I cannot
fathom why. Anyway, for anyone else with the same problem, this is what
fixed it. I simply removed .Text from the code so the sample I gave
became:

textbox1.setfocus
textbox1 = RecordSetName!fieldname

instead of:

textbox1.setfocus
textbox1.Text = RecordSetName!fieldname

Why that should make a difference I have no idea, especially as in the
previous application it worked fine with the.Text in place.

Can anyone come up with an explanation? Please!!
 

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