Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access 2007/2010 not running VB Code from 2003 DB

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
US
We are updating some of our old 2003 DB's to 2007/2010. I have noticed some of the VB code from the 2003 DB is not doing its job when the DB is converted to 2007. I have gone into VB and compiled the code and nothing shows as being wrong. Here is the code (snipped...there is a lot more of the same type):

Forms![Employee Frm]![Accesses Subform].Form![Server Share Subform].Form.Form.AllowEdits = True
Forms![Employee Frm]![Accesses Subform].Form![Server Share Subform].Form.AllowAdditions = True
Forms![Employee Frm]![Accesses Subform].Form![Server Share Subform].Form.AllowDeletions = False

Should this be changed somehow because it is in 2007 now instead of 2003? Example please.

Sorry, the code button on this site did not work so I just pasted it into the body of this message.

Thanks
 
The code TGML has alwasys worked for me. I noticed a duplicate .Form in the code. Can you clarify "not doing its job"?

Code:
Forms![Employee Frm]![Accesses Subform].Form![Server Share Subform].Form[COLOR=#CC0000][highlight #FCE94F].Form[/highlight][/color].AllowEdits = True
Forms![Employee Frm]![Accesses Subform].Form![Server Share Subform].Form.AllowAdditions = True
Forms![Employee Frm]![Accesses Subform].Form![Server Share Subform].Form.AllowDeletions = False

Duane
Hook'D on Access
MS Access MVP
 
Code may be because I am using an XP computer.

Not doing what it is suposed to do means: The code is not setting the form to Add and Edit mode when it runs. I have these forms locked sort of in a view only mode until changes need to be made by the proper people. When, the proper people, select a control on the form...the code runs. I checked the control and the after update event is there and that is where the code is triggered. Other parts of the code are working but not these type of items. So, I know the After Update event is triggering and doing something, but not everything.

Thanks Duane
 
I know how to add the break point but where should I put it...at the start of the code or at the start of the failing code. Then do I just use the Form Control to start the code...or do it all in VB.

I am learning here....thanks,
 
OK..I set the break point and clicked the control to start the process. I stepped through everything and everything worked except these commands shown above. I then removed the double Form.Form...to just Form. Ran it again...same issue. I am going to show more code. There are three groups of code. The code above is one piece of each group. I am now going to show you and entire group. Everything in this code works except for the top line...one of the three above. Can you see anthing that could cause a problem?
Code:
       [COLOR=#EF2929] Forms![Employee Frm]![Accesses Subform].Form![Server Share Subform].Form.AllowEdits = True[/color]        Forms![Employee Frm]![Accesses Subform].Form![CGS Subform].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![QA CGS ROLES SELECTON].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![DEV CGS ROLES SELECTION].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![APC Subform].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![QA MAPC ROLES SELECTION].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![DEV MAPC ROLES SELECTION].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![Docu Rolls Subform].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![Docu QA Rolls Subform].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![Docu DEV Rolls Subform].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![Military Subform].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![Military QA Subform].Form.AllowEdits = True
        Forms![Employee Frm]![Accesses Subform].Form![DPT Rolls Selection].Form.AllowEdits = True
 
Duane,

Do you mean after the code runs? No. Before the code runs? No. Source records are editable. Remember...this works when run in Access 2003. All I did is convert the DB to a 2007 version. The form gets its data directly from a table, no query. All fields in the table are editable. The form has a dropdown list that is bound to one of the fields in the table. It also has two check box controls also bound to table fields. The form is shown in Continuous Forms view. Allow Additions, Deletions, and Edits are all set to No on the form. The code is suposed to control these items to turn them to True or False depending on what control is clicked causing the code to run. In this case I turn edit, and additions to True and leave Delete as false. The rest of the forms, shown in code above, are all set the same but...they work.

Thanks for working through this with me. Is there another way to control these settings? I know Set Properties does not list these settings, Allow Edit etc.
 
After running the code from the after update, I would query the setting by opening the debug window (press Ctrl+G) and entering something like:

Code:
? Forms![Employee Frm]![Accesses Subform].Form![Server Share Subform].Form.AllowAdditions

Duane
Hook'D on Access
MS Access MVP
 
Won't get to it until the AM...but I will get to it. Thanks again
 
Hook'D on Access (Duane)
Sorry I am so late with this but other work took priority. I did what your asked above and the results = True. So, where to from here?

A little more info. I have a 2003 copy of the DB on my WIN 7 computer with Office 10.
I have another copy of the DB that has been upgrade to 2010 on the same computer.

Both exibit the same problem.

I have a copy of the 2003 version of the DB on my other computer...XP..and Office 2003. Works fine.

So, something about either version of the DB when running on WIN 7 Office 10.
I have not had any problems with other DB's with Office 10..only this one.

Thanks
 
Duane,

Yes, With the form open...and the code having been run, I can still update the table.

I want to make sure I explained correctly. After the code runs all my sub forms EXCEPT my MT Server Sub-form show a blank record for entry. The MT Server sub-form does not allow me to add a new record.

I just turned my navigation back on for the form and the * for new record is greyed out.

Yet..the form properties show (Data)
Data Entry Yes
Allow Additions Yes
Allow Deletions Yes
Allow Edits Yes
Allow Filters Yes
Record Locks No Locks

Thanks,
 
OK...thanks for sticking with it. I will let you know if I find an answer.
 
Unfortunately, sometimes when you try to convert files into a newer format, old code doesn't work exactly right for no reason at all. I've seen this happen with macros in spreadsheets. Even though it shouldn't make any difference, I've found that if you end up copying all of the data (e.g., table, forms, macros) from the existing file into a new file in the newer version of the software it will sometimes work.
 
I would consider recreating the subform. Possibly create a new blank form and copy/paste controls and set properties. There might be some issue with corruption.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top