Read and write only on textbox ?

  • Thread starter Thread starter SpookiePower
  • Start date Start date
S

SpookiePower

I have made a simple form with some textboxes showing data about some
customers
from a table. I can see it is possible to edit data about the customer
just by edit the text in the textboxes. But is it possible to make the
textboxes read-only so that the user not will be
able to edit the data ?

My next question is -
I want to put a edit-button on the form (I know how to place a button
on the form) and when the
user push this button, the textboxes will turn to write/read-only and
the user can make some
changes to the data. How can I do this ?





www.photo.activewebsite.dk
 
Spookie,

Set the Enabled property of the textboxes to No, and their Locked
property to Yes.

You can then use a VBA procedure on the Click event of your command
button to reverse this, with code along these lines...
Me.NameOfControl.Enabled = True
Me.NameOfControl.Locked = False
 
Thanks, it works just fine.

I have another question :)

Insted of closing the form and choose save, when I have made some
changes to the
textboxes, I would like to place a "save-changes" button, that saves
the changes.

What would this code look like, that saves the changes ?

I know how to do some VBA code when working with excel, but I have
never
made code til access, so i'm not sure how those two things works
together.
 
It is a simple one liner:

Me.Dirty = False

However, controling when and whether changes to a record are updated is not
that simple. There are several things that can cause the record to be
updated without a Save button. Any time you move to another record or if you
close your form or requery your recordset, pending updates will be applied.
If you want to control the form so that no update can occur without the Save
button, you will need to take these factors into consideration.
 
Thanks.

I found out as you point, that saving just by using a button, is more
complex
than I thought. So I found another way around my problem.
 
Back
Top