473,699 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code has broken after upgrade to Access 2010

112 New Member
I have just upgraded to Access 2010 (64 bit) from Access 2007. There were a few minor issues in the database which I have resolved but this one piece of code just won’t work. I do not write VBA but have a rudimentary understanding of it. This code was not written by me and I am still trying to understand why it doesn’t work? I have posted the code below; this is what it is supposed to do: I have a main form that displays each record. The form is run from a query that combines one main table and 3 sub tables. The code is connected to a button on a pop-up form that when clicked, deletes the current record on the main form, from all the tables that it is run off. The problem is nothing happen? I don’t even get an error message and request to debug? I am hoping that it is a simple change that has to do with the upgrade as it worked in 2007. Any help is appreciated.

Thanks
Expand|Select|Wrap|Line Numbers
  1. '---------------------------------
  2.     'Declaration of the variables
  3.     '---------------------------------
  4.  
  5.     Dim rs As Recordset         'recordset use to get the objectId of the current record
  6.     Dim QuerySelect As String   'represents the query to gather info
  7.     Dim ObjectID As String      'represents the deleted objectId
  8.  
  9.     '--------------------------------
  10.     'End of declaration
  11.     '--------------------------------
  12.  
  13.     'Close the RecordControlBox
  14.     DoCmd.Close acForm, "frmRecordControlBox"
  15.  
  16.     'Retrieving data from the record to be deleted
  17.     QuerySelect = "Select ObjectID From Description where Description.[Accession Number] = '" & Forms!frmDescription!txtAccNum.Value & "'"
  18.     Set rs = CurrentDb().OpenRecordset(QuerySelect)
  19.  
  20.     'going to the last record then come back to the first to make RS.RecordCount effective
  21.     rs.MoveLast
  22.     rs.MoveFirst
  23.  
  24.     'check if there is only 1 record, should not delete a whole bunch of record at the same time
  25.     If rs.RecordCount = 1 Then
  26.  
  27.         ObjectID = CStr(rs![ObjectID])
  28.  
  29.         'building all the queries to delete every objectId in every table
  30.         CurrentDb().Execute ("DELETE FROM [Condition Info] WHERE [Condition Info].[ObjectID]= " + ObjectID)
  31.         CurrentDb().Execute ("DELETE FROM [Treatment Info] WHERE [Treatment Info].[ObjectID]= " + ObjectID)
  32.         CurrentDb().Execute ("DELETE FROM [DigitalImageDetails] WHERE [DigitalImageDetails].[ObjectID]= " + ObjectID)
  33.  
  34.         Forms!frmDescription!rcdcontrol.SetFocus
  35.         DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
  36.         DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
  37.  
  38.     Else
  39.         MsgBox "An error occured while retrieving ObjectID of the artifact. No record have been deleted"
  40.     End If
  41.  
  42. Exit_rcdelete_Click:
  43.     Exit Sub
  44.  
  45. Err_rcdelete_Click:
  46.     'MsgBox Err.Description + "kgkgkg"
  47.     Resume Exit_rcdelete_Click
  48.  
  49. End Sub
May 23 '13
11 2700
Redbeard
112 New Member
Thanks zmbd that fixed it! I followed you steps and was able to fix all the errors. After I changed Line 23 to the code you suggested and did a Compile, it gave me an error on Line 39, like you predicted. (Run-Time error 3601, Too few parameters Expect 1) The ObjectID field for my DigitalImageDet ails table is DIObjectID and not ObjectID as it is for all the other ones. Once I fix that it all ran smoothly.
Thanks
May 27 '13 #11
zmbd
5,501 Recognized Expert Moderator Expert
YEA!

Now, two simple things to finish up fixing your code:
Back to Post#9

First:
Line 2: Re-enable your error trapping (Appears I mentioned ";" should have said single quote.." ' " opps - too many programing languages under the old hat. In any case, you should re-enable the code.

Last:
Lines 53 thru 57
Currently read:
Expand|Select|Wrap|Line Numbers
  1. Err_rcdelete_Click: 
  2.     'MsgBox Err.Description + "kgkgkg" 
  3.    ' Resume Exit_rcdelete_Click 
  4.  
Your error message/trap is "disabled" and what is there would be only mildly helpful; however, in this case, even with the minimum, it might have helped you find the error sooner if it had been enabled.
What I suggest is to change this code to something (IMHO) useful such as:
Expand|Select|Wrap|Line Numbers
  1. 'DEFAULT ERROR TRAP
  2. '
  3. 'make sure you have zj_errorlocation defined.
  4.     MsgBox Now() & vbCrLf & _
  5.         zj_errorlocation & vbCrLf & _
  6.          Err.Number & vbCrLf & _
  7.            Err.Description, vbExclamation, _
  8.             "DEFAULT ERROR TRAP"
  9. '
  10. Resume exit_from_error_to_cleanup
  11. '
That last resume line takes my code back to a section where I check that all recordsets are closed and pointers are released.
The "zj_errorlocati on" is just a variable I set at the beginning of my modules so that when the users report error I can tell which module/form the error is occurring. It can be omitted.
May 27 '13 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4577
by: phill86 | last post by:
Hi, I have an access 2010 database that I want to convert to an SQL Server database and I need to know if the data macros in access will still work in the SQL database or will i have to create triggers in the SQL Sever database Many Thanks Phill
5
12422
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I finished working with the database and return it to my pc(which has access 2007) I can't get it open because Access say that the file is not the right format. Does anyone have a way to work around this compatibility problem? So you know I...
2
6708
by: sierra7 | last post by:
It seems Access 2010 is associating an 'input mask' or field type with a combo box when a form is opened, even though there is no Format setting on the control. I have a form which has been running OK for years in Access 2003; it adds an item selected from an inventory listing to either an existing Sales Order or Purchase Order. For historic reasons Purchase orders are alphanumeric and Sales orders are numeric (long integer). The RowSource...
2
7188
by: dougancil | last post by:
I have a user who had deleted some records from a database today using Access 2010. They have an ID field that's autonumbered. They have No Duplicates allowed. When they created a new record today, it was recreating numbers that had already been assigned but deleted. I've read a couple of articles about resetting the autonumber in Access, but I'm wondering if this is the only way to really fix this issue? Has anyone else came up with a work...
0
1708
by: Andolino | last post by:
In Access 2010 I get a Write Conflict error - "This record has been changed by another user..." In Access 2007 this Code is working - why? Private Sub Form_BeforeUpdate(Cancel As Integer) Dim dbs As DAO.Database, rst As DAO.Recordset, strCriteria As Variant Set dbs = CurrentDb Set rst = dbs.OpenRecordset("Artikel", dbOpenDynaset) strCriteria = " =" & Me.
1
5262
by: Alan Yim | last post by:
Hi folks, My company recently upgraded our Office suite from 2003 to 2010. The problem in particular is with an Access database that was originally designed in Access 2003. The code in question used work in 2003 (see below code). Private Sub engSave_Click() Dim strSql3 As String 'Archive order number and cost data for engine.
5
49039
by: colsoft | last post by:
I am using Access 2010. Am generating reports for the records, one record per page. The records on the even pages have a light black background shading which appears when am printing. Please i need help on how i can remove those background shading.
2
7318
by: Bill Boord | last post by:
I need to be able to shut off the AutoCorrect "feature" within Access 2010 code. I have utilized Application.SetOption with method strings for other startup requirements, but I cannot seem to find a correct method string to turn off the text replace "feature." I am not talking about the "Track Name AutoCorrect Info" method, but rather the method that corresponds to the checkbox if one were to enter Access 2010 and click File, Options,...
1
8481
dsatino
by: dsatino | last post by:
I have numerous applications built in Access 2000/2003 that all use ODBCdirect workspaces to access various non-Access databases. Unfortunately, ODBCdirect is 'no longer supported'in Access 2010 and when my associates get new PC's, the applications fail. The error message says to switch from DAO to ADO. This is a little curious since ADO is dying/dead as well. I'm hoping someone can add a little insight/best practice to my situation.
1
3430
by: Music Man | last post by:
Greetings All: I built a database in Microsoft SQL Server 2000 and used Microsoft Access 2010 as the front end. The database is used to keep track of "issues" that rise out of my employment. I've been there a long time and now feel the need to start documenting certain occurances. I have 4 tables, one of which is a table called fileattachments. I'm storing the path to the files in this table and the actual files are stored in a directory...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9033
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7748
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.