473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Deleting Forms in other Database stops with error 2051

The following code is working In 97 but not in 2000
(start and finish are indicated by <<<<<<<<<<<< and >>>>>>>>>>>)
This action has to clean the specified database so, that delete all but
specified forms;
it is called from elsewhere by
call DelSaveFormsNew( dbfile, "f01",f02",...
In 97 this works as expected.
In 2000 deleting is not performed, when commeenting "on error" line in
deleteObject function and error 2501 is coming.
What could be reason for this.
<<<<<<<<<<<<<<<<<<<<<<<<<<<
Sub DelSaveFormsNew(DbFile As String, ParamArray FormsSaved() As Variant)
Dim intI As Integer

Dim dbs As Database, ctr As Container, doc As Document

' Returns reference to current database.
Set dbs = OpenDatabase(DbFile)
' Returns referenct to Forms container.
Set ctr = dbs.Containers!Forms
' Enumerates through Documents collection of Forms container.
For Each doc In ctr.Documents
' check if it is in array
For intI = LBound(FormsSaved()) To UBound(FormsSaved())
If doc.Name = FormsSaved(intI) Then
intI = 1000
End If
Next intI

If intI < 1000 Then
Debug.Print "to be deleted "; doc.Name
Debug.Print "DeleteObject(dbfile,acForm, doc.Name) = ";
DeleteObject(DbFile, acForm, doc.Name)

Else
Debug.Print "to be saved "; doc.Name; " intI=", intI
End If
Next doc
Set dbs = Nothing
End Sub
>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<
Public Function DeleteObject(Filename As String, _
objType As Integer, _
objName As String) As Boolean
On Error GoTo DeleteObject_Err
Dim accObj As New Access.Application
accObj.OpenCurrentDatabase Filename
accObj.DoCmd.DeleteObject objType, objName
accObj.CloseCurrentDatabase
Set accObj = Nothing
DeleteObject = True

DeleteObject_End:
Exit Function
DeleteObject_Err:

Resume DeleteObject_End
End Function
>>>>>>>>>>>>>>>>>>>>>>>>>>>

--
V.Moltchanov

Nov 12 '05 #1
1 2410
Vlasislav,

"Vladislav Moltchanov" <vl******************@ktl.fi> schrieb im
Newsbeitrag news:c8**********@oxygen.ktl.fi...
The following code is working In 97 but not in 2000
(start and finish are indicated by <<<<<<<<<<<< and >>>>>>>>>>>)
This action has to clean the specified database so, that delete all
but specified forms;
it is called from elsewhere by
call DelSaveFormsNew( dbfile, "f01",f02",...
In 97 this works as expected.
In 2000 deleting is not performed, when commeenting "on error" line
in
deleteObject function and error 2501 is coming.
What could be reason for this.


Did you check the references?

Use dao.database instead of database

Peter
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nathan Bloom | last post by:
Hi, I have a data entry form (access 2000) that also allows the user to add, update, and delete records from the form. The Delete action is carried out in an event procedure and has the...
1
by: Coy Howe | last post by:
This one seems bizarre! We have a database consisting of a main table and 12 - 15 "sub" tables, which are connected via cascading relationships. The database performs many complex calculations...
1
by: dixie | last post by:
I am trying to adapt some code so that when I double click an entry in a multi-select list box, the entry represented by that entry is deleted from the table. The code I am trying sort of shows...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
46
by: DP | last post by:
hi, i've got a form, with a subform in it. i've got a delete button in the subform. the code i;ve got is; Private Sub cmdDeleteRecord_Click() msg = "Are you sure you want to delete this...
7
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
1
by: sphinney | last post by:
All, I'm not sure how to adequately explain my problem in two sentences or less, so at the risk of providing TMI, here's the condensed verion. I have developed an Access 2002 database file that...
4
by: sphinney | last post by:
I'm not exactly sure how to start this post. My question is pretty simple, but it will take a little bit of context before I can state it. (And thanks in advance for taking the time to read this!) ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.