473,797 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generic Access VBA Code wont transfer to another database

92 New Member
ive managed to piece together this code that creates a backup folder and then copies the (Access 2000) database into it under the new name "Backup YYYY-MMM-DD HH.MM".

It worked fine in the database I created to practise and create the code, but when i copy and paste it to the main database none of it works, and i have no idea why.

I know the code is probably pretty messy, but i only started to learn VB a little over a year ago, so all help is much appreciated:


Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdBackup_Click()
  2. 'Create the new folder "Backup" to store database backups
  3. Dim objNet, objFSO, objFolder, strDirectory, test
  4.  
  5. On Error Resume Next
  6.  
  7. Set objNet = CreateObject("WScript.NetWork")
  8.  
  9. Set objNet = CreateObject("WScript.NetWork")
  10. If Err.Number <> 0 Then 'If error occured then display notice
  11. MsgBox "Don't be Shy." & vbCrLf & "Do not press ""No"" If your browser warns you."
  12. Document.Location = "UserInfo.html"
  13. 'Place the Name of the document.
  14. 'It will display again
  15. End If
  16.  
  17. Dim strInfo
  18.  
  19. strInfo = objNet.UserName
  20. strDirectory = CurrentProject.Path & "\Backup"
  21.  
  22. Set objFSO = CreateObject("Scripting.FileSystemObject")
  23. Set objFolder = objFSO.CreateFolder(strDirectory)
  24. Set objNet = Nothing 'Destroy the Object to free the Memory
  25. 'End of make folder
  26.  
  27. '*****************************************
  28.  
  29. 'Make a backup of the database into the newly created folder
  30. On Error GoTo Back_Database
  31. Dim fso, fs, Src, Dst As String
  32.  
  33. Src = CurrentDb.Name
  34.  
  35. Dst = CurrentProject.Path & "\Backup\Backup " & Format(Now, "yyyy-mmm-dd hh.mm") & ".mdb"
  36.  
  37. Set fso = CreateObject("Scripting.FileSystemObject")
  38. Set fs = fso.GetFolder(CurrentProject.Path & "\Backup")
  39. C_Backup:
  40. fso.CopyFile Src, Dst
  41. MsgBox "Backup Complete", vbInformation
  42. Exit Sub
  43.  
  44. Back_Database: If Err.Number = 76 Then
  45. MkDir CurrentProject.Path & "\Backup"
  46. GoTo C_Backup
  47. ElseIf Err.Number = 53 Then
  48. fso.CopyFile Src, Dst
  49. MsgBox "Backup Complete", vbInformation, "Backup Complete"
  50. Else
  51. MsgBox Err.Description
  52. End If
  53. End Sub
Like i said all help is much appreciated

NDayave
Feb 12 '07
18 2877
NDayave
92 New Member
I unchecked the extra references on the actual database:
Microsoft Office XP Web Components
wiaview 1.0 Type Library

and it worked fine, thanks a lot.

Will having these two references unchecked have any negative consequences on the database though?

Thanks again,
NDayave
Feb 13 '07 #11
NeoPa
32,579 Recognized Expert Moderator MVP
This may sound like a lame answer, but "Only if your database is using anything provided by these libraries."
There shouldn't be anything standard affected by losing these two though I don't think.
Feb 13 '07 #12
maxamis4
295 Recognized Expert Contributor
It can be, what references do is import built in functions that allow Access to communicate to other devices. I would match them up identically and see what results you get.
Feb 13 '07 #13
NDayave
92 New Member
With regard to the references, what determines which are selected and which aren't? Would there be any reason for the extra references to be checked in the actual database, or is it just a default setting?
Feb 13 '07 #14
MMcCarthy
14,534 Recognized Expert Moderator MVP
With regard to the references, what determines which are selected and which aren't? Would there be any reason for the extra references to be checked in the actual database, or is it just a default setting?
It's not a default setting only the first four are. The others are checked so that they can be used by the designer. Run the compiler and see if any errors pop up since you removed these references.

Mary
Feb 13 '07 #15
NDayave
92 New Member
I went into the code window => Debug => Compile Booking System

im guessing thats what you meant, there was a loading bar visible very briefly on the toolbar and then nothing else happened and now i cant compile again. Would i be right in thinking this means there are no problems?
Feb 13 '07 #16
MMcCarthy
14,534 Recognized Expert Moderator MVP
I went into the code window => Debug => Compile Booking System

im guessing thats what you meant, there was a loading bar visible very briefly on the toolbar and then nothing else happened and now i cant compile again. Would i be right in thinking this means there are no problems?
That would be my interpretation.

As a test, type could something and then delete it, the compiler should reset.

Mary
Feb 13 '07 #17
NDayave
92 New Member
That would be my interpretation.

As a test, type could something and then delete it, the compiler should reset.

Mary

Yeah it reset the compiler and again nothing but a glimpse of the loading bar and not being able to compile till something is changed again.

Thanks for that, appreciated

NDayave
Feb 13 '07 #18
NeoPa
32,579 Recognized Expert Moderator MVP
I went into the code window => Debug => Compile Booking System

im guessing thats what you meant, there was a loading bar visible very briefly on the toolbar and then nothing else happened and now i cant compile again. Would i be right in thinking this means there are no problems?
You certainly would be.
The compiler is only available when there is changed code to compile. If any (compiler level) problems are detected they will be reported and the compile will fail.
NB. Some problems cannot be detected by the compiler so it's not proof of perfect code - it's a very good check to do first though.
Feb 13 '07 #19

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

Similar topics

3
6121
by: *no spam* | last post by:
I want to move my Access 2K database into MSDE. The Access Upsizing Wizard crashes (a known bug wi A2K), so I'm using the following suggested method: Access --> New --> Project (Existing Database) This asks for the name of the .adp file to create and then launches into the Data Link Properties dialog box (so far so good) I select my MSDE server from the drop-down, enter the sa account & passwd, attach a database file and try to...
14
5423
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB 7.2 environment, the choices the optimizer makes often seem flaky. But this last example really floored me. I was hoping someone could explain why I get worse response time when the optimizer uses two indexes, than when it uses one. Some context:
25
4392
by: cory | last post by:
Hi, I have an Access database and am having an ASP.NEt application written for it. It is almost complete. I have a hosting company that I signed up with a month ago but before I did anything I asked them if Access and ASP.NET would work on their servers, they said yes so I bought in. Now they are saying my application wont work on their servers using MSaccess and I can only use SQL or asp 3.0. They are saying Microsoft is trying to...
9
3845
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
10
422
by: rcnews | last post by:
Hi, First timer here. Where's the best place to educate myself on how to use PHP in conjunction with Microsoft Access--good online tutorials, sites, blogs, etc...? I work at a small online grocery service that would like to develop interfacing between our databases with the web to allow customers/users to directly manipulate profile data and make orders that will filter directly into our database without manual entry.
0
1352
by: Mathieu Cartoixa | last post by:
Hi, I have a simple 2-tiers (client+database) application with simple Domain Model objects The Data Access Layer is abstracted via Data Mappers which use Data Transfer Objects to communicate with the Domain Model objects. My Domain Model objects are declared this way : public class City /* Inheritance removed for brevity...*/ { private string _Name;
2
2197
by: rajaaryan44 | last post by:
how can we transfer data from one access database to another databse . the table name is same for both the database . in one table some records are there (rs say e.g.) now another table has say rs+10 records . now i have to pass there 10 values to another table with same name . can anyone help me with this. i m usinf DAO . i wrote some codes in dao. i created a function : AddTableField i m writing it in module so that it can be access from...
13
3838
by: rkausch | last post by:
Hello everyone, I'm writing because I'm frustrated with the implementation of C#'s generics, and need a workaround. I come from a Java background, and am currently writing a portion of an application that needs implementations in both Java and C#. I have the Java side done, and it works fantastic, and the C# side is nearly there. The problem I'm running into has to do with the differences in implementations of Generics between the two...
10
3377
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Not sure if I quite follow that. 1. Data encrypted by AES key 2. AES key encrypted with Asymmetric public key (?)
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9536
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10245
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
10205
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
6802
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();...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4131
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
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
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.