To Edit or Not to Edit

L

lj

I'm sure there is a simple answer to this, but it eludes me at the time:

I have a form with a tab control. On one of the pages, there is a subform. I
would like to have the three text boxes on that subform to be read-only when
you access that page, and only editable if you click a button if you need to
change the information (it would be a rare occurrence).

Can anyone give me some simple code to accomplish this?

ljr
 
S

Steve Schapel

LJ,

In the design view of the form that is used as the subform, set the
Allow Edits property of the form to No. Then, in the On Click event
property of your command button, use this code...
Me.AllowEdits = True
 
N

Nick Howes

You can do this with a macro or with VB code (right click on button and
choose Build Event)
Say you have your button, and your text boxes box1, box2, box3.

macro:

assign a macro for when you click on the button.
make an action "SetValue", and either type in or
use the "..." to open expression builder, something like

[Forms]![My Form]![Box1].[Enabled]

and type True in the Expression field. Add a couple of
more actions to do the same for the other boxes, and save.

VB:

code section should a little look like this:

Private Sub MyButton1_Click()
Me.Box1.Enabled = True
Me.Box2.Enabled = True
Me.Box3.Enabled = True
End Sub


hth
 
L

lj

Thank you both for your prompt response and helpful tips. I had to fiddle
around a little bit because the button is on the form not the subform, but I
got it to work. Thanks again.

lj


Nick Howes said:
You can do this with a macro or with VB code (right click on button and
choose Build Event)
Say you have your button, and your text boxes box1, box2, box3.

macro:

assign a macro for when you click on the button.
make an action "SetValue", and either type in or
use the "..." to open expression builder, something like

[Forms]![My Form]![Box1].[Enabled]

and type True in the Expression field. Add a couple of
more actions to do the same for the other boxes, and save.

VB:

code section should a little look like this:

Private Sub MyButton1_Click()
Me.Box1.Enabled = True
Me.Box2.Enabled = True
Me.Box3.Enabled = True
End Sub


hth

lj said:
I'm sure there is a simple answer to this, but it eludes me at the time:

I have a form with a tab control. On one of the pages, there is a
subform.
I
would like to have the three text boxes on that subform to be read-only when
you access that page, and only editable if you click a button if you
need
to
change the information (it would be a rare occurrence).

Can anyone give me some simple code to accomplish this?

ljr
 

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