Modules & VBA :: Batch Copy And Rename

Jun 25, 2013

This code is supposed to loop around a directory of photos (named after a project), and then copy a new photos (from another directory) to this folder, numbering them and the logging them in a table tphotos.The first time a copy photos to a new directory the code works fine. And I think I had it working fine before, but now when I copy photos to a pre-existing directory that has already photos, it only overwrites the first photo, instead looking for the last photo and attributing the new photo number n+1.

I've done debug.print in the code, and it looks like is not going into If NewFileName = f1.Name, therefore doesn't compare the newfilename with the files in the folder.

Code:
Private Sub cmdAddPhoto_Click()
Dim fs, f, f1, fc, s
Dim fDial As FileDialog
Dim SourcefileName, destDir, FileExt, NewFileName, prjID As String
Dim intSel, FileNumber As Integer
Dim varSelFile As Variant
Dim rsPhoto As Recordset
Dim myDB As Database

[code]...

View Replies


ADVERTISEMENT

Modules & VBA :: Copy And Rename Excel File To Subfolder With Name Entered In Forms Control?

Jan 5, 2014

I am still trying to copy an Excel file from a parent folder to a sub-folder, that this code creates, and name the copied file with the name used to name the sub-folder, using the name entered in a control field (named 'TheDirName) of an Access 2007 form. Here is my VBA, which names the copied file "TheDirName.xlsx.:

Private Sub MakeDir_Click()
Dim appExcel As Excel.Application
Dim lngLastDataRow As Long
Dim Folder_Path As String
'Create path for customer folder & files

[code]....

View 3 Replies View Related

Copy / Paste / Rename A Field In Same Form?

Apr 25, 2014

In the Contacts database, in the Report Center form are 5 links on the right pointing to some default reports.I have created several more reports, and want to just copy-n-paste those links and then change the 'Tag' so it will point to my new report.Can you not just copy-n-paste a field within the same form?

View 5 Replies View Related

General :: Copy Network Folder To Another Location And Rename It

Jul 17, 2013

I'm looking for copy folder functionality and I can't find anything.

In access 2007 when I push a button on a form, I want to copy a network folder to another location and rename it.

View 1 Replies View Related

Cannot Export, Import, Copy/paste, Rename Table With Data!

Feb 22, 2006

Hello everyone.

I've been in a new position for a new company for less than three weeks, and I need some help.

The Access database that we use has been in operation since 2002, and it has never been Compacted/Repaired (I asked my coworkers and supposed IT people, and they said "what's that?").

After adding *one* new field, I've reached the horrific "error 3190" (max 255 fields).

I've tried all of the following, allowing at least 12 hours for them to run, but I cannot:
export the data to Excel
import the data into a new database
copy/paste the records (because there are 12100+ and the max is 9500, I think; and because of the way the dd/mm/yy converted itself to dd/mm/yyyy)
or rename the table with the data.

Please, someone help me.

View 1 Replies View Related

General :: Batch File To Allow Users To Copy Latest Version Of Front End Whenever Change Made

Aug 7, 2014

I have been trying to set up a batch file to allow users to copy the latest version of the front end whenever a change is made. The following is the code that I am trying to get to work properly. The first part works fine, the old front end is copied to a folder on the user's desktop as a backup. But I cannot get the copy of the server - the "P" drive, to overwrite the current copy on the user's desktop. Actually I cannot get the code to copy the new front end from the server and install it on the user's desktop. I think the path is correct for I seem to be able to run the new front end from the server.

When I look for the location on my computer, the server locations is listed as:

General (Servernamefiles) (P: ) (there is no space after the P: it seems to result in a smiley face when I type it and try to post it).

for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set year=%%c
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set month=%%a
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set day=%%b
set TODAY=%year%-%month%-%day%
rem echo %TODAY%

[Code] .....

This code works so I thought that the path was correct
rem this works
rem start the new DB front end
Start P:AccessMainSplitBENewFrontEndDBMain.accdb

But this code does not.
echo f | xcopy /f/y/ P:AccessMainSplitBENewFrontEndDBMain.accdb c:UsersUserNameDesktopDBMain.accdb

Neither does this:
echo f | xcopy /f/y/ ServerNamefilesP:AccessMainSplitBENewFrontEn dDBMain.accdb c:UsersUserNameDesktopDBMain.accdb

View 2 Replies View Related

Modules & VBA :: Cannot Rename A Report

Dec 17, 2013

I want to rename a report by clicking a command button on a form. I have this simple code in the click event:

Dim strReportNameNew As String
Dim strReportNameOld As String
strReportNameNew = txtChangeTo.Text
strReportNameOld = txtChooseReport.Text
DoCmd.Rename strReportNameNew, acReport, strReportNameOld

The code fails with this error message:

Microsoft Visual Basic

Run-time error '29068'

Household Labels cannot complete this operation. You must stop the code and try again.

I am able to rename the report manually.I have searched but been unable to find out what is causing this error.

View 6 Replies View Related

Modules & VBA :: How To Rename Table

Jul 16, 2013

I'm having about 100 table with the following name: phres01, phres02, phres03 .....phres100

And I need to rename them to ph01, ph02, ph03 ... ph100 respectively

thus removing the "res" part of each table. Since the ctrl+h doesn't work for access LOL im in hella trouble.

View 10 Replies View Related

Modules & VBA :: Backup Backend Using Batch File?

Aug 14, 2014

I've created some code to make a backup of my database backend. I've tested it and it seems to work fine, I just have some questions about it's use. Here's the code:

Code:
Public Sub backupBackend()
Dim TestFile As String
Dim strReplFile As String
Dim copyFromLocation As String
Dim copyToLocation As String
copyFromLocation = "S:Trust 2 AnalysisData"

[code]....

It will be triggered by a button push. It creates a batch file to do the copy operation and then delete itself.

In an ideal world I would schedule the backup at a safe time through the Windows scheduler, but our IT department won't allow me to do so.

The concern I have is that we could potentially press the backup button while a user is performing an action that writes/modifies data. If this were to happen would my backup potentially contain corrupted data?

If so, is the workaround to simply press the backup button when nobody is using the database?

View 3 Replies View Related

Modules & VBA :: Replace Batch Number From All Tables

Jan 23, 2015

I have 4 tables with a field that holds a "batch number" there can be many batch numbers in these fields.I want if possible to replace a batch number from all my tables that contains that data and replace it with another batch number in one go. is a macro the only way to do this.I would like a macro that asks me the batch number to replace and then asks me the number to replace it.

View 14 Replies View Related

Modules & VBA :: Rename PDF Attached To Email

Dec 13, 2013

I'm using 2013. The first version of my code works great. It opens the correct report and attaches it to an e-mail as a pdf with all of my text etc.

Code:

Private Sub btnEMail_Click()
On Error GoTo errHandler
Dim strReport As String
Dim vMsg As String
Dim vSubject As String
Dim strWhere As String
strReport = "RptJobDSD"

[Code] ....

The problem I have is I would like to rename the pdf, so instead of "RptJobDSD" everytime, it can have some fields [DSDDate] and [JobID] etc.

Before trying the fancy field stuff I thought I'd try just "DSD Test" and see if I could rename it in the first place!

I added this and am getting - Error(32004) - The control name 'RptJobDSD' is misspelled or refers to a control that doesn't exist.

Code:

DoCmd.OpenReport strReport, acViewPreview, , strWhere
DoCmd.SetProperty strReport, acPropertyCaption, "DSD Test"
DoCmd.SendObject acSendReport, strReport, acFormatPDF, , , , vSubject, vMsg, True

My confusion comes as the OpenReport and SendObject recognise strReport why doesn't SetProperty?!

View 2 Replies View Related

Modules & VBA :: Creating A Batch File To Open Up Another Database

Mar 11, 2015

I want to create a batch file that will be used in a RunApp macro command to open up another database.

View 2 Replies View Related

Modules & VBA :: Rename Table To First Column Heading

Feb 25, 2015

I am importing different excel sheets into Access dB using a file dialog. The importing works fine however, I would like to rename the tables once they are imported to the name of the first column heading. Where exactly would I ad the name change at in this code?

#' Open the EXCEL file and read the worksheet names into a collection
Set colWorksheets = New Collection
Set objWorkbook = objExcel.Workbooks.Open(StrFileName, , blnReadOnly, , _
strPassword)
For lngCount = 1 To objWorkbook.Worksheets.Count
colWorksheets.Add objWorkbook.Worksheets(lngCount).Name

[Code] .....

View 2 Replies View Related

Modules & VBA :: Rename Table - Append Current Date On The End

Jul 2, 2014

I am using access 2010. I need to rename a table when I import the a new table. But I can't get the docmd rename code to work. I also want to append the current date on the end i.e.

docmd.rename, "tblOldTable(Currentdate)", actable, "tblOldTable"

doesn't work.

View 10 Replies View Related

Modules & VBA :: Creating EXE Or BATCH File That Executes Specific Excel Macro?

Jan 27, 2015

Is there a way to create some sort of an EXE or BATCH file in any Windows Explorer folder, that executes me a specific Excel Macro?

My problem is that I got several files split up by Departments, updated every day.

So far I have to open each file and update the format.

It would make my life much more easier if I could just run a file that opens each file and applies a format to them.

View 1 Replies View Related

Modules & VBA :: Import Csv Files And Rename Them After Import Into (imported) And (failed)

Jul 17, 2015

I have the following piece of code for importing the .csv files from a selected folder and then renaming them into 'imported & filename' if succesful and 'failed & filename' if import failes for whatever reason (bad formating, etc.).

The problem is that the first time it encounters a 'bad' file after another, instead of going again to the Error handler, the command

Code:
DoCmd.TransferText acImportDelim, , "Activitate", filename, True

gives me the default MS Access error, namely 2391. I would like it to go the the Error_handler again ang follow the course of actions and rename the files into 'failed' and 'imported'.

Here's the code:

Sub ImportActivitate()
Dim strFile As String 'Filename's
Dim strFileList() As String ' File Array
Dim intFile As Integer 'Number of files
Dim filename As String, sFullName As String, sFilename As String
DoCmd.SetWarnings False

[code]....

Also, how can I make the routine stop cycling through the files after I renamed them all?

View 3 Replies View Related

Modules & VBA :: Copy Value To 2nd Table

Jun 18, 2014

I have a database with two tables, and a form that is bound to the 1st table. I have a duplicate record button on the form. One of the functions I want to happen is when the duplicate button is pressed, one value is copied from the form and added to the 2nd table. The tables are basically set up the same with an ID column which is the key and an autonumber, and the second value is a number. So I want to copy the number to the other table and add a record. What is the best method? Can I use an insert into and just copy from a variable, or is the better method with a recordset. Either way, I have not been able to figure this silly thing out and it is preventing me from moving forward with this database.

View 11 Replies View Related

Modules & VBA :: Copy Record From One Form To Another?

Nov 14, 2013

ok so I have two forms open: One is a SP Bookings form with a subform SPDetails Query subform. The other form is the not connected/related SP Contacts Query form, to which users enter Full Name weight age ect. Need to copy the names of the new customers Full Name to the Lookup Contact Column in SPDetails Query subform. I got this far, with my trial runs are commented out. The only thing it does when I click on the button is move to new record on Sp Contacts Query Full Name and Copy the previous record. How do I get the button to copy the Full Name from form SPContacts Query.Full Name to the SPBooking Query.subform SPDetails Query Subform.LookupContact

Code:
Private Sub Command52_Click()
Me.Full_Name.SetFocus
DoCmd.RunCommand acCmdSelectRecord

[Code].....

View 3 Replies View Related

Modules & VBA :: Copy File From One Folder To Another

Feb 28, 2014

I need to create a function that I can launch using a macro that will copy an excel file from one folder to another in the file system.

View 4 Replies View Related

Modules & VBA :: Copy Records To 2nd Table

Mar 28, 2014

I'm getting myself into a bit of a muddle.

I have four tables:
tblinvoice / tblinvparts
tblquotes / tblquoteparts

when I open the tblinvoice form it has tblinvparts as a subform. tblinvoice has a listbox that lists quote numbers linked to vehiclereg. I have a button on the tblinvoice that will open a popup tblquoteparts continuous form linked to the quoteid on tblinvoice. These filtered records have a select button so I can select all or some.

I have now got stuck as I need a button on tblquoteparts popup that will copy the selected records from tblquoteparts and paste them into tblinvparts where quote (on tblequoteparts)=quoteid in tblinvoice.

In a nutshell, I would like to copy selected records from tblquoteparts to tblinvparts.I need to duplicate the records because only 10% of invoices are generated from a quote and the quote parts/prices may differ from the final invoice.

View 9 Replies View Related

Modules & VBA :: Creating Read Only Copy Of BE DB

Sep 2, 2014

I have searched and have not been able to find anything on creating a read-only copy of a back end DB with VBA. I am creating backups of my back end file and would like to create a local read-only copy to use in the event that the regular back end is not available. The code I am using to create the backup is:

Code:
Public Function BackupBE()
'On Error GoTo BackupBE_Err
Dim sourceFile As String, destinationFile As String
Dim aFSO As Variant
Dim path As String, name As String

[code]....

View 9 Replies View Related

Modules & VBA :: Copy Worksheet From One Workbook To Another

Sep 24, 2014

I am currently trying to copy a tab from one workbook ("List.xls") to another ("IGEN_QC.xls") but I keep getting an error:

Method 'Copy' of object '_Worksheet' failed

Code:
Sub copydata()
Dim wkbSource As Workbook
Dim wkbDest As Workbook
Dim shttocopy As Worksheet
Dim wbname As String
On Error GoTo ErrHandl

[code]...

View 2 Replies View Related

Modules & VBA :: Copy Value From Current Form To A Table

Aug 27, 2013

I have a projects Database with: Projects_Table, Staff_Table.

Both tables has forms for data entry or update. Each project has many staff allocated to it.

In the Staff_Form I placed the Project_Code in the form heading section. The form opens based on a search criterion on the project_code so it shows the staff for that project only. The issue is when I try to add a new staff for that project on the Staff_Form, the project_code stays blank in the staff_table.

What I need is that the project_code in the staff_table for that newly added person to have the same project_code on the opened form. Simply to link the staff to the project they work in when I add them using the form.

View 1 Replies View Related

Modules & VBA :: Copy A Control In Form Design?

Oct 24, 2013

I need to duplicate a number of controls on a form. They are all acCommandButton types, but they have different images, sizes etc.

Anyway, my thought process was if I have a "template" acCommandButton then when I create my new controls if I could use this template then the code I have hanging off them (I have a function being called on the onClick event, borders are set to hairline, themes turned off and various other settings) would be copied. Save me trying to set them all individually.

So, my question is, can I "copy" a control in form design through VBA. Once I create the copy of the control I can then change the couple of properties I need to and "hey presto" I have skipped a load of settings that I don't need to set.

At the end of the process when I rename my form I can delete my template control and I have a working form.

View 7 Replies View Related

Modules & VBA :: Copy Current Record From Recordset To Csv

Aug 4, 2013

I have a DAO.recordset called "rsSQLIn". This comes from a csv file by:

Code:
strSql = "SELECT * " _
& "FROM [Text;Database=" _
& strFolder _

[Code]....

While the validation runs a boolean keeps track of validated input and errored input.

After validation the validated input is dumped in the table.

Now what I want is de saving the errored record from "rsSQLIn" to be copied to a new .csv file.

The problem I have is that I cant seem to get the current record from the recordset "rsSQLIn". How do I reference this? I need the complete set of 24 fields being the same within "rsSQLIn"

View 3 Replies View Related

Modules & VBA :: Copy Field1 To Field 2 In Table

Feb 20, 2015

I want to save the timestamp created in a table when a user opens the database. My vba saves the computer name and user name and sets the currentuser = yes. The table is mysql odbc, and has the requisite timestamp and id fields. I have a form that I can open that shows who is online at that moment. When a user closes the database, the currentuser field is set =no. All of that works well. Now, I have added a "starttime" field in which I would like to store the timestamp that was set upon opening, since when a user logs off, the timestamp gets changed to the log off time.

Code:

Dim myQry As String
Dim sUserName As String
Dim sUserComputer As String
Dim currentVersion As Date

[code]....

The UserTimestamp in red is the field value of the first record in the table, not the usertimestamp in the user's record. How do I store the log on timestamp in the "starttime" field?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved