Full Version: Add "Reviw Mode" & "Edit Mode" Option Group??
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
jodidew
I would like to add an option group with two variebles:
1. "Edit Mode" - when clicked enables user to edit record data
2. "Review Mode" - when clicked locks all bound controls so that data may not be edited.

I am sure there is some easy code in VBA to do this, and in fact I found some for command buttons, but so far I am unable to do this for an option button.

Can anyone help me here or point me in a good direction??

Also, does anyone know of any good classes in advanced Access and Beginner/Intermediate VBA in the MD/VA/DC area that last less then a week? I have gotten to the point in alot of the database I am building where it is over my head and I need some formal training.

Thanks, Jodi
freakazeud
Hi,
welcome to UA forums.
What's the difference between a command button and option button? If you found code for the one you can use it in the other.
For your other question, I know of learningtree, which is heavily involved in the MD/DC/VA area. I'm not sure about the quality of their classes. You can look up everything they offer, where and when online. Seems pricy, but then again I can't comment on quality or compare them to anything else.
HTH
Good luck
ScottGem
If Me.OptGroup = 1 Then
Me.AllowEdits = True
Else
Me.AllowEdits = False
End If

Put that inthe After Update event of your Option Group. This assumes that Edit mode is given a value of 1 in the group.
BrianS
THis should do it. This is assuming the option group is called "MyOptionGroup" and it is location on the form you wish to lock.
CODE
Select Case Me.MyOptionGroup
    Case 1
         Me.AllowAdditions = True
         Me.AllowEdits = True
         Me.AllowDeletions = True
    Case 2
         Me.AllowAdditions = False
         Me.AllowEdits = False
         Me.AllowDeletions = False
End Select
jodidew
Thanks so much for the quick responses!!

I added this code:

Private Sub OptReviewEdit_AfterUpdate(Cancel As Integer)
Select Case Me.OptReviewEdit
Case 1
Me.AllowAdditions = True
Me.AllowEdits = True
Me.AllowDeletions = True
Case 2
Me.AllowAdditions = False
Me.AllowEdits = False
Me.AllowDeletions = False
End Select
End Sub

But I am still running across the same problem as with the command buttons. When the "Review Mode" option is clicked then it works and I cant change any data. But it wont let me click on the "Edit Mode" option so that I can start editting the data.

I do want the default to be set to "Review Mode" when the form is first opened.

Any suggestions on what I may be doing worng??

Thanks Jodi
jodidew
This is the popup error message I am getting when trying to run the above code:

The expression On Load you entered as the event property setting produced the following error:

Procedure declaration doesnt match description of event or procedure having same name

*expression may not result in the name or a macro, the name of a user-defined function
*there may have been an error evalution of the funtion, event, or macro
Gecko
Create a new form with your original form as a subform.

Put your your option buttons on the new form then...
Private Sub OptReviewEdit_AfterUpdate(Cancel As Integer)
Select Case Me.OptReviewEdit
Case 1
Me.subFormName.Form.AllowAdditions = True
Me.subFormName.Form.AllowEdits = True
Me.subFormName.Form.AllowDeletions = True
Case 2
Me.subFormName.Form.AllowAdditions = False
Me.subFormName.Form.AllowEdits = False
Me.subFormName.Form.AllowDeletions = False
End Select
End Sub

This is untested but it should look something like this...
Jack Cowley
When you set Allow Edits to false then you cannot make a selection from your option group. In the On Enter event of the option group use code like this:

Me.AllowEdits = True

Put this code in the On Click event instead of the After Update event:


Select Case Me.OptReviewEdit
Case 1
Me.AllowAdditions = True
Me.AllowEdits = True
Me.AllowDeletions = True
Case 2
Me.AllowAdditions = False
Me.AllowEdits = False
Me.AllowDeletions = False
Me.Refresh
End Select

hth,
Jack
jodidew
This gets rid of the error message, but now it always keeps it in review mode. Even when "edit mode" is clicked on, it still wont let me edit anything??

I set the default to Review Mode. Would this have anything to do with it???

Thanks
jodidew
Jack,

That worked!! Thanks!!!

One side question: Is there a way to reset back to the default "Review Mode" after switching to the next record??
niesz
Since you want to always reset to 'Review Mode' when entering a different record, why not get rid of the option group all together and just put an Edit button on your form?

On the OnCurrent event of the form, run this code:

Me.AllowAdditions = False
Me.AllowEdits = False
Me.AllowDeletions = False

And on the command button OnClick event:

Me.AllowAdditions = True
Me.AllowEdits = True
Me.AllowDeletions = True

This will reset to 'Review' any time you move to a different record and allow edits to the current record when the button is clicked.
Jack Cowley
See the response by 'niesz' about putting the code in the On Current event to set the properties to No.

I'm glad the solution worked for you and the code for the On Current event suggested by 'niesz' will fix your last problem.

Jack

PS. If you click on Reply to the right of the members avatar the the member you are responding to will get a notification that you have responded. If you use the Quick Reply then your post may be 'attached' to your previous post and no one knows that you have responded unless they look at the entire thread.

Edited by: Jack Cowley on Thu Nov 17 14:59:10 EST 2005.
jodidew
Thanks Jack/niesz!

The only thing with the command button is my boss doesnt like it frown.gif

He wanted the option or check boxes.

Does On Enter mean when entering a record? I tired looking it up but my Access 2002 VBA handbook didnt say anything about it. I tired pasting the opposite code in On Exit and it didnt work.

Also, I couldnt find a On Current event in my form properties. I did have a Current when in the VBA code.

Is there any code that reads On Next Reccord....?

Last question, would you be able to reccoment any classes (less then 1 week long) for beginner/intermediate VBA and advanced Access. I really need some formal training on this.

Thanks! Jodi
Jack Cowley
On Enter is an event of the Option Group so when you 'enter' this event it sets the AllowEdits to True so you can click on the Edit button or the Review button. If you don't do this then clicking in the Option Group does nothing as it is 'locked'.

Open your form in Design mode and where the rulers come together in the upper left corner there is a gray square there. If you click in the square a solid black square will appear. This means that the Property Sheet you are looking at is for the form. Now if you open the property sheet (if it is not open already) and click on the Event tab the first event is On Current. Put the code suggested by niesz there.

I do not know what you mean by "...code that reads On Next Record" so give some details on what you are want to do and one of us will try to help you.

I never had any classes (sometimes it really shows!) so I do not have an answer for that question. If you frequent UA you will find tons of answers here and LOTS of members that are willing to assist you.

Jack
jodidew
Jack,

Well I just put in this code (thanks to you telling me where it was frown.gif ) in the Form_Current section, and it worked!! Now everytime I switch to a new record, it set the option button to "Review" mode and doesnt allow any edits unitl I click on the option "Edit Mode".

Private Sub Form_Current()
Me.AllowAdditions = False
Me.AllowEdits = False
Me.AllowDeletions = False
Me.OptReviewEdit = 2
End Sub

I love it when things work!

Thanks, Jodi

PS Can you reccomend any good books on this subject??
Jack Cowley
Jodi -

Yeah, it is cool when a plan finally comes together! I'm glad to hear that you have everything workng as you want. Now you are happy and so is the boss!

As far as a book... I started when Microsoft gave you huge manuals with Access but those days are gone forever. Consequently I have not used any books (again, sometimes it shows!) but I would suggest that you go to your local book seller and look at all the books on Access (there are lots of them!) and find one that is a bit more than you need right now and then go for that one. Books are expensive so take your time and be sure you find one that will be not obsolete in a month...

Good luck!

Jack
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.