Hello,
I have the code below. It used to work but now for some reason access breaks when running with error code 2486, "You can't carry out this action at present time.". - Private Sub btn_archive_Click()
-
Dim objAcc As Object
-
Dim objAcc2 As Object
-
Dim filename As String
-
filename = InputBox(prompt:="Type your file name here.")
-
If Len(filename) = 0 Then
-
MsgBox "No file name chosen"
-
Exit Sub
-
End If
-
-
Set objAcc = New Access.Application
-
objAcc.OpenCurrentDatabase ("P:IBA Delinquency DB Data.accdb")
-
objAcc.DoCmd.CopyObject "P:IBA Delinquency DB Archive.accdb", filename, acTable, "tl_delinquency"
-
-
objAcc.CloseCurrentDatabase
-
-
Set objAcc = Nothing
-
MsgBox ("Your data has been archived, " & filename & "!")
-
Any assistance is greatly appreciated!
Thank you!
-Al
9 1765
Al,
As with any other problem report, it's important to give all of the details. Have you stepped through this with the debugger to see where the error is happening?
Perhaps your drive P: is not available? Maybe it would help if the code included the full path instead of just "P:", even if the full path is only "P:\"
You might try doing this "manually" to see if you can discover anything that is not obvious letting VBA handle it.
Do the DBs involved get compressed from time to time?
Jim
Your lines 12-13 should be: - objAcc.OpenCurrentDatabase ("P:\IBA Delinquency DB Data.accdb")
-
objAcc.DoCmd.CopyObject "P:\IBA Delinquency DB Archive.accdb", filename, acTable, "tl_delinquency"
You need the backslash, even if the file is in the root directory.
The full path works. Also, the backlash "\" is there on the code. I just took it out when copying.
full path of the code.
P:\Travel Card Program\Delinquency DB\IBA Delinquency DB\IBA Delinquency DB Data.accdb
After the error code pops up. (From the initial inquiry up top). The code below is highlighted: - objAcc.DoCmd.CopyObject "P:\Travel Card Program\Delinquency DB\IBA Delinquency DB\IBA Delinquency DB Archive.accdb", filename, acTable, "tl_delinquency"
aflores,
Now that I look at the rest of that line, it looks like you may be using the incorrect method. Try using the Transfer Database method, which allows you to more easily transfer objects between two databases.
Your original post is trying to copy a table as a database....
I had the error 13, "type mismatch" for the code below after modifying to transfer database rather copyobject. - Dim objAcc As Object
-
Dim objAcc2 As Object
-
Dim filename As String
-
filename = InputBox(prompt:="Type your file name here.")
-
If Len(filename) = 0 Then
-
MsgBox "No file name chosen"
-
Exit Sub
-
'ElseIf filename = "Data Entry_tbl" Then
-
'MsgBox "Change file name"
-
'Exit Sub
-
End If
-
-
Set objAcc = New Access.Application
-
objAcc.OpenCurrentDatabase ("P:\Travel Card Program\Delinquency DB\Delinquency DB Data.accdb")
-
objAcc.DoCmd.TransferDatabase "P:\Travel Card Program\Delinquency DB\Delinquency DB Archive.accdb", filename, acTable, "tl_delinquency"
-
-
objAcc.CloseCurrentDatabase
-
-
Set objAcc = Nothing
-
MsgBox ("Your data has been archived, " & filename & "!")
-
[qry_Delinquent 51 subform].Requery
-
[qry_Delinquency Frequency subform].Requery
-
[tl_delinquency_staging subform].Requery
-
[qry_list of delinquency subform].Requery
-
[tl_delinquency_tracker].Requery
-
Application.SetOption ("auto compact"), 1
-
Me.TabDelinquency.Value = 0
Where is the error happening? Which line?
If it is Line 15, then it could be a confusion in the arguments: - objAcc.DoCmd.TransferDatabase _
-
acImport, _
-
"P:\Travel Card Program\Delinquency DB\Delinquency DB Archive.accdb", _
-
acTable, _
-
filename, _
-
"tl_delinquency"
Also, is the "Delinquency DB Archive.accdb" the file you are currently in or the DB from where the source table is. Your descriptions and question are not altogether clear, so we have to guess at exactly what you are trying to do.
Additionally, with this method, I don't believe you have to actually open the DB (setting objACC), you just execute the code.
So there's three databases: - Delinquency DB - Front End - this is where the code is
- Delinquency DB Data - Store Data - takes data from here
- Delinquency DB Archive - Archive Data - store data here
aflores,
Have you have able to experiment with this method?
The code worked before and It's not working now. I don't know why. I'll keep researching. Thanks Twinn.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Henri |
last post by:
Hello,
I am quite new to ms-sql and I have a problem : I want to create an SQL
request which would copy serveral records from a table in a given database
to another table (with exactly the same...
|
by: ChrisA |
last post by:
Hi all,
we are developing an internal application that involves "Timesheets",
"Support" and "Project Management".
Imagine that there are 3 different databases for the above scenario,
under SQL...
|
by: Bill Moran |
last post by:
Boy, I'm just full of questions today ...
Is there a way to provide different persistent settings for DateStyle for
different databases within the same cluster?
Simply put, I've got two...
|
by: ShyGuy |
last post by:
Is ther a way to copy a table, from the backend of a split database,
into a database on another machine from the front end?
|
by: prabhun2004 |
last post by:
hi all
i use postgresql database.
There are two databases in that namely 'db1','db2'.
In 'db1', thers is a table named as 'table_common'.
In 'db2', there is a table named as...
|
by: shanthimanooj |
last post by:
hi i need the code in qtp Compare two different Databases .that means comp two schemas no of tables,no of colums in a tables,no of rows in a table,
|
by: Dammit |
last post by:
Hi!
My first post in this great forum. :)
Here goes:
I need some feedback on best practice (or just possible practice!) on creating a copy of a table from one SQLserver to another SQLserver.
...
|
by: asi242 |
last post by:
Hello,
Good day to all...
I just want to ask.. How would you connect two tables from 2 different databases using PHP scripts? Because, one database that contains customer table is dedicated to...
|
by: alter.fire |
last post by:
Hey im trying to do the following in PHP:
Connect to 2 different databases, one named complete and one
incomplete.
My goal is to find whats missing in the "incomplete" database.
The fields...
|
by: dougancil |
last post by:
I have two different databases on the same server using SQL 2000. Every night database 1 is updated via an automated process. I currently have an query that will then move that data to a "static"...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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,...
|
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...
|
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: 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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |