Changing FormProperties

  • Thread starter Thread starter chowlett
  • Start date Start date
C

chowlett

I have a Service Order Form that is initially opened in read only form. I
would like to add a couple of command buttons to the form so that a user can
change over to edit or add mode without having to go back to the main page
of the database. Can someone show me how this is done in VBA.

TIA
Casey Howlett
 
Here is some simple event code - the first two are for Edit and New record
buttons. The AfterUpdate event resets the form properties to disallow
additions and edits. The Current Event resets the AllowAdditions property in
case a user starts to enter a new record and then leaves it without acutally
doing anything. This should be enough to get you started.


Private Sub cmdEdit_Click()
Me.AllowEdits = True
End Sub


Private Sub cmdNew_Click()
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
End Sub


Private Sub Form_AfterUpdate()
Me.AllowAdditions = False
Me.AllowEdits = False
End Sub

Private Sub Form_Current()
If Not Me.NewRecord Then
Me.AllowAdditions = False
End If
End Sub
 
Thanks Sandra,
After seeing the answer to some of my questions I don't feel like a rocket
scientist so I guess its a good thing that I am not one. I tried the the
Me.AllowEdits several times and it kept telling me that it was expecting an
expression or something. DUH! Your help is greatly appreciated and have
patience with my stupid questions, I am trying to learn. Do you know of a
good publication that is written in "English" for begginers such as myself?

TIA
Casey
Sandra Daigle said:
Here is some simple event code - the first two are for Edit and New record
buttons. The AfterUpdate event resets the form properties to disallow
additions and edits. The Current Event resets the AllowAdditions property in
case a user starts to enter a new record and then leaves it without acutally
doing anything. This should be enough to get you started.


Private Sub cmdEdit_Click()
Me.AllowEdits = True
End Sub


Private Sub cmdNew_Click()
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
End Sub


Private Sub Form_AfterUpdate()
Me.AllowAdditions = False
Me.AllowEdits = False
End Sub

Private Sub Form_Current()
If Not Me.NewRecord Then
Me.AllowAdditions = False
End If
End Sub


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have a Service Order Form that is initially opened in read only form. I
would like to add a couple of command buttons to the form so that a user
can change over to edit or add mode without having to go back to the main
page of the database. Can someone show me how this is done in VBA.

TIA
Casey Howlett
 
Here are a couple of links to book lists - I haven't read all of these - my
absolute favorites that are specific to Access are the Access Developers
Handbooks by Litwin, Getz and Gilbert (and Gunderloy) on the 2002 edition I
believe. Though they are my favorites, they are*not* beginner books -

In addition to staying involved in the newsgroups and using groups at
google.com you might want to check these links -

http://www.viescas.com/Info/books.htm#Access
http://www.mvps.org/access/resources/books.htm

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
Thanks Sandra,
After seeing the answer to some of my questions I don't feel like a rocket
scientist so I guess its a good thing that I am not one. I tried the the
Me.AllowEdits several times and it kept telling me that it was expecting
an expression or something. DUH! Your help is greatly appreciated and
have patience with my stupid questions, I am trying to learn. Do you know
of a good publication that is written in "English" for begginers such as
myself?

TIA
Casey
Sandra Daigle said:
Here is some simple event code - the first two are for Edit and New
record buttons. The AfterUpdate event resets the form properties to
disallow additions and edits. The Current Event resets the
AllowAdditions property in case a user starts to enter a new record and
then leaves it without acutally doing anything. This should be enough to
get you started.


Private Sub cmdEdit_Click()
Me.AllowEdits = True
End Sub


Private Sub cmdNew_Click()
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
End Sub


Private Sub Form_AfterUpdate()
Me.AllowAdditions = False
Me.AllowEdits = False
End Sub

Private Sub Form_Current()
If Not Me.NewRecord Then
Me.AllowAdditions = False
End If
End Sub


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have a Service Order Form that is initially opened in read only form.
I would like to add a couple of command buttons to the form so that a
user can change over to edit or add mode without having to go back to
the main page of the database. Can someone show me how this is done in
VBA.

TIA
Casey Howlett
 
Back
Top