How can I add an edit record button

G

Guest

Hi,

I would like to add an 'edit record' button to my form. Can anyone help
getting me started on doing this. I'm pretty new to Access so am not that
familiar with it. Do i need to change the data in the table
in order for this to work? If so how can i create a button that takes me to
the relevant item in the table?

Thanks
Jamie
 
G

Graham R Seach

Jamie,

Unless you've done something wierd, you already have the ability to update
(edit) the data in the form. Why do you think you can't?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
G

Guest

Thanks for the reply Graham,

I had locked the fields as i want to be able to share the database on the
network and didn't want people accidently altering stuff. There is probably a
very simple way arouns this but as i say i am a bit of a novice.

Cheers
 
G

Guest

I think what I did was add this to the form "on current" event:

Private Sub Form_Current()
Me.AllowEdits = False
End Sub
____________

Then, I added a control button to the form, just cancelled the wizard for
it, clicked on it, clicked on the "on click" event, and added this:

Sub MyEditButton_Click()
Me.AllowEdits = True
End Sub
_____

After that, I went and added/formated the text/picture for the button.

Seems to work ok.

I'm no expert though.
CW
 
G

Guest

Terrible explanation by me!

When I say "clicked on the 'on current'" and "clicked on the 'on click'"
events, what I meant is clicked on them in the properties window, and then
chose the (...) button that appeared and "code builder" to get to where the
code goes.

Also, the beginning and ending lines are already included when you do that,
so all you have to add is the middle line with the AllowEdits in it.

CW
 
G

Graham R Seach

OK, all you need to do is add a button, and add the following code to it's
Click event:
Me.AllowEdits = True

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
G

Guest

Many thanks for the help.

Jamie

Graham R Seach said:
OK, all you need to do is add a button, and add the following code to it's
Click event:
Me.AllowEdits = True

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
G

Guest

Hi CW,

I have followed what you advised but when i click on the button i have
created nothing happens. Do you think i may have other settings wrong. What
should i expect to happen if it is alright?

thanks
Jamie
 
G

Graham R Seach

Jamie,

If all you have is that code in the form's Current event, then all you'll
need is the code I gave you. When you say "nothing happens", did you
actually try modifying the data, or were you expecting something else to
happen?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
G

Graham R Seach

Jamie,

So you know whether the record is locked or unlocked, you can add the
following line to the Current event:
Me.Caption = strPreviousCaption & " (Locked)"

....where strPreviousCaption is the form's caption that you've set. You can
use a literal string if you wish:
Me.Caption = "myFormName (Locked)"

....and then in the button's Click event:
Me.Caption = strPreviousCaption

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 

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