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 Replies


ADVERTISEMENT

Modules & VBA :: Create Subfolder And Copy File - Path Is Variable

Apr 18, 2014

I have a folder which holds 1000s of pictures organised in subfolders, for example:

D:~AI Database Print Scans2009family and
D:~AI Database Print Scans2009holiday

And so forth. In total at the moment 17 main subfolders, each of which hold another 2-3 subfolders.

I am putting together a database to bring pictures together with all sorts of details. I import the picture via hyperlink and complete the various fields. All that works fine but there are a lot of pictures! And it gets confusing to see which ones have already been entered into the database and which ones haven’t.

One solution for this is to copy the pictures that have been “completed” to another folder. I have found a way to do that:

Dim fs As Object
Dim oldPath As String, newPath As String
oldPath = Forms!frmPrintDetails.txtPath1
newPath = "D:~AI Database Print ScansCompleted_Entries"
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile oldPath, newPath
Set fs = Nothing

Works fine, but the problem is that I loose the subfolder structure, it copies all pictures to the same main folder. I’d like to maintain the subfolder structure and add code to create the correct subfolders and next copy the picture. With the different paths I’m lost. I don’t know how to extract the correct path in code. I’d also like to either rename or remove the picture once I have completed entry of the details. The problem I have again is that I don’t know how to code for a changing path.

View 12 Replies View Related

Modules & VBA :: Copy Paste Excel File From Access

Mar 31, 2015

All I need to do is copy an excel file from a location (while coping the file, the location of the source file remains same all the time)and paste that excel file where ever I want (Browser Option) from an Access VBA.

View 4 Replies View Related

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 5 Replies View Related

Modules & VBA :: Copy Excel File Or A Table In Access To Specific Location On FTP Server

Jul 11, 2013

I need some simple code that will copy an Excel file or a table in Access to a specific location on an FTP server. I would think this would be a very simple task, but I have yet to find any sample code that is *simple*. I have seen lots of code that requires downloading this dll or that mda, but the examples don't work. There must be something built into MS Access 2010 that will allow a file to be uploaded to an FTP site.

All the variables are known:

The FTP location (it never changes)
The FTP Username and Password (they never change)
The destination folder on the FTP site (it never changes)
The File type (it never changes)
The File name (available from the form in Access from which this will be executed)

I can either produce an output file, then copy it to the FTP site, or I can export the table directly to the FTP site with the file name for that day.

This seems to be a very simple task with no simple solution. Currently I am using an FTP app to get the file to the FTP site, but I would like to automate this. The process that creates the output file is already automated, so I would just like to add this to the existing code as its own module.

I'm looking for a simple command on the idea of:

DoCmd.FTPFile, acExel, TableName, FTPFilePath, FTPFileName, Username, Password, acUpload

just made all that above up and none of it is a real function/command in VBA, but is just the kind of thing I'm looking for.

I would think that since I can download and XML file from an FTP site that it should be child's play to upload a simple file to an FTP site, but I can't figure it out.

View 8 Replies View Related

Rename Access File With Excel Pivot Table Link

Jan 8, 2007

Hi,
I would like to rename my access file. My problem: I have many pivot in excel link to this database so if i rename it all the links will be down...How can i resolve this?:confused: (of course rebuild all pivots could be a solution but I have around 50 pivots behind my database)
Thanks for your help!

View 1 Replies View Related

How To Copy Value From Access Table To Excel File Without Losing Number?

Jul 27, 2007

This forum is really helpful!

I am using following code to copy low value from Access table to excel file, but only to find that it changed in excel file. How should I do to not change that?

ThisWorkbook.Sheets("EV Data").Cells(row + 2, col + 2) = _
rs.Fields(col).Value



RecordIDDateTimeStampSetupIDStringBaseProductIDStringMGDBIDStringVAGLBIDStringPWDCohortIssueAge1IssueAge2NumberOfCellsNumberOfScenariosTotalWeightInitialPremiumEV_MeanEV_P995EV_P99EV_P95EV_P90EV_P75EV_P50EV_P25EV_P10PrEVGTZero
51907/27/2007 7:04:36 PMAccess2006Max72006MGIBAllCombinedAllCombinedAllCombined95010.006800000006810000009.33604218011769E-03-2.48487734766947E-02-2.35810657931309E-02-1.44083677074442E-02-1.10775676515645E-02-2.1878002261516E-037.92060932296671E-031.95193525290664E-023.06835072412068E-020.70658682634731
52007/27/2007 7:04:37 PMAccess2006Max7LifePayIAllCombinedAllCombinedAllCombined185010.005110000001.19424841908013E-02-1.67115163990304E-02-1.42187111112351E-02-8.08910871821918E-03-4.62961276311795E-032.72200376166994E-031.04312882683217E-022.06668892126601E-022.96649979111015E-020.80638722554891
52107/27/2007 7:04:37 PMAccess2006Max7NoneAllCombinedAllCombinedAllCombined95010.0054410000007.98908918707603E-03-1.67789382388317E-02-1.56490361783179E-02-1.07703746693193E-02-0.00753365556878-7.10709517675212E-046.72111941423526E-031.59418102675589E-022.44078788510759E-020.730538922155694
52207/27/2007 7:04:37 PMAccessRat2006MGIBAllCombinedAllCombinedAllCombined95010.0030199999969810000009.52176602967384E-03-1.56233866973614E-02-1.49901562045925E-02-8.41152147122661E-03-5.44762510232609E-034.05576508882054E-047.33588282834675E-030.0164686012768352.61950530898991E-020.754491017964078
52307/27/2007 7:04:37 PMAccessRatLifePayIAllCombinedAllCombinedAllCombined185010.00226499999773510000001.06805510377118E-02-0.014626108301625-1.20428523073918E-02-6.08984658852046E-03-2.22851888030373E-034.04428276871694E-039.82402795120803E-031.68655595406923E-022.40410662469335E-020.856287425149709
52407/27/2007 7:04:37 PMAccessRatNoneAllCombinedAllCombinedAllCombined95010.00241599999516810000005.8666292477999E-03-1.13844546795139E-02-1.04027261898336E-02-6.72766534794549E-03-4.77103336054974E-03-3.11542830732602E-044.5158867397345E-031.06654135236169E-021.76803347713142E-020.730538922155694

View 7 Replies View Related

Forms :: SQL To Run After Data Is Entered Into Form Control

Aug 3, 2015

I have a form that the user enters employees daily duties. I have code to run sql after the BoxNum field has data in it. I want it to look at the BoxNum field and the dropdown box for the task to see if the entered box number has already been completed for the task selected on the form. Here is what my code looks like now. The code runs but gives me the msgbox no matter if it is a made up box number and I also get a syntax error 3075.

Code:

Private Sub Text13_BeforeUpdate(Cancel As Integer)
Dim rs As DAO.Recordset
Dim strSQL As String

[code]....

View 6 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

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

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

Modules & VBA :: Determine Excel File Type Without Opening The File?

Aug 14, 2015

Question: Is it possible, using VBA, to determine the actual Excel file type without opening the file?

I receive data files from other departments. Seems like every time someone changes their download structure, I end up with file types that do not match the download extension (example: xlm file with a xls extension). The files can't even be opened because of this. I think I can fix it if I could figure out how to determine what the file type really is.

I'm using Office 2010.

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 :: Test If Main Folder And Subfolder Exist

Mar 1, 2015

I'm having problems creating a second subfolder in the main folder.

The main folder is used to keep inside the reviews of clients inside.

The code I have now, will only create a main folder if it does not exist and then a subfolder with the BIN nr, type review and date. If the client would have a diferent ones and in diferent years. So if it has first "Prototype Model", the next one could be "Prototype Review". The part of the code that checks if the main folder exist works, but how to let the code create in the main folder the second review subfolder? Please see below code I managed so far:

Code:
Private Sub btn_Create_Folder_Click() 'XXXXXXXXXX working onXXXXXXXXXXXXXX
Dim path1 As String
Dim path2 As String
path1 = "C:Test_FolderMedium" & Me.BIN & "_" & RTrim(Me.LE_Name) & ""
path2 = "C:Test_FolderHigh" & Me.BIN & "_" & RTrim(Me.LE_Name) & ""

[Code] ...

How to have the code test both of them?

View 14 Replies View Related

Rename A Control

Dec 17, 2007

Can i rename a control on the fly ? For example, if Me!Office = 6 Then Me.Branch9 = Me!Branch. Both branch9 and branch are fields in the table products

View 1 Replies View Related

Modules & VBA :: How To Open Treeview Node To A Specific Folder / Subfolder

Dec 18, 2014

I have a tree-view object that is filled with a specific folder list, when a command button is pressed I would like too expand to a specific node based on a variable/foldername.

How to achieve this? My knowledge of tree-view is limited and I am still learning VBA.

View 2 Replies View Related

Modules & VBA :: Copy And Paste Current Record Only To Excel

Jul 13, 2014

Its been a few years since I used Access, and despite searches I cant find what I'm looking for. I have a VERY simple form, with only one record on it - "address". I have some print buttons which will print that address to different size labels, and some navigation items, but only one actual record - which is "address" (in the table, this address is a MEMO)

I would like to have a command button that when clicked copies the current record, and opens an existing Excel Spreadsheet and pastes that address into (for example) cell C8

Can it be done easily? Is there a DoCmd.TransferSpreadsheet kind of secnario that works with current record only?

View 8 Replies View Related

Modules & VBA :: Copy File To New Directory On Button Click?

Dec 22, 2014

Is it possible in access, to create a button that will copy a file to a new directory? Specifically, the data field in question is an access hyperlink that we can click on to open a PDF drawing of a part. I just want to copy the file the hyperlink points to, into a new directory.

EX:
X:database/drawings/somefile.pdf
X:erp/drawings/somefile.pdf

I don't think a macro can do this, but perhaps vbscript can.

View 2 Replies View Related

Modules & VBA :: Copy Zipped File To Another Location And Unzip

Apr 28, 2015

How easy it is to add a button to a form with a function to copy a zipped file to another location and unzip it?

View 10 Replies View Related

Modules & VBA :: Copy From Excel And Paste Directly To Access From Clipboard

May 28, 2015

I am copying a range from excel (multiple rows) and paste it directly to access table using:

Code : DoCmd.RunCommand acCmdPasteAppend

Sometimes it does not work and I need to use paste special as text.

Is there any way to paste special as text using VBA ?

View 3 Replies View Related

Modules & VBA :: Copy Query Info To Specific Excel Cells

Mar 7, 2014

I have spent the day using Access 2010 and attempting to move information from a parameterized query into specific cells in an excel template. It runs smoothly until I attempt to reference the query at which point I run into th error "Too few parameters. Expected 1." Currently my reference code looks like this:

Dim T As Recordset
Set T = CurrentDb.OpenRecordset("SELECT [8D Data].ID, [8D Data].[Customer Closed], [8D Data].[Days Open], " & _
"[8D Data].[Open Date] , [8D Data].[QN #], [8D Data].[Last Report Date], " & _
"Leaders.[Leader Name] , Leaders.[Leader Title], Leaders.[Leader Phone #], " & _
"Leaders.[Leader Email], [8D Data].[Part Description], [8D Data].[Customer P/N], " & _
"[8D Data].Customer , [8D Data].[Vehicle Year], [8D Data].[Problem Description]" & _
"FROM [8D Data] INNER JOIN Leaders ON ([8D Data].Lead = Leaders.ID)" & _
"WHERE ((([8D Data].ID)=[Enter QCR #]));")

View 4 Replies View Related

Modules & VBA :: Access Memo Field Copy To Excel Truncates At 255 Characters

Nov 25, 2013

Two Solutions to address moving an Access Memo field into Excel when string has > 255 characters. All my 'reports' use Excel VBA (Access Reports are not used). The Excel reports can have 40,000 records. Speed to create the report can be an issue.

Describing 2 Solutions below to address moving Access memo fields with > 255 characters into Excel.After running this code

Code:
720 ObjXL.DisplayAlerts = False
ObjXL.Columns("X:X").Select
ObjXL.Selection.NumberFormat = "@" ' set column to Text
730 ObjXL.Worksheets(intWorksheetNum).Cells(intRowPos, 1).CopyFromRecordset rsNutsAndBolts

The Comments column are limited to 255 characters. So, the CopyFromRecordset (recordsetvariable) creates the 255 character limitation.

The reason? The 255 character limit is because CopyFromRecordset sutomatically uses the Characters property of the Range object. The 255 limit would not be there if the Cell Value property is used to assign the string to that cell.

Dim sRx as String ' String Prescription
sRx = "String with > 255 characters ... you fill in the rest ...."
Cells(1, 1).Value = sRx ' Cell's Value property assignment can be very large

Solution 1:

The record set is still in memory. By using a loop, a cursor can start with record 1 (memo column) and assign that value to the Excel row / column using the .value as shown above. Basically, this moves one memo field at a time, record by record. e.g. Read First recordset in Access, copy to variable, assign value to Excel row/column Then move next on each Access and Excel.

Solution 2:

An Access Memo filed [RxNotes] can have up to 750 characters. Cut it apart into three new fields that end up out in the very right Excel columns AA, AB, AC.

Note1=Mid([RxNotes],1,250)
Note2=Mid([RxNotes],251,250)
Note3=Mid([RxNotes],501,250)
Then using Excel Object - Concat the cells back cell by cell...
X2=CONCATENATE(AA2,AB2,AC2))

Then delete the columns AA, AB, AC to hide the evidence..Neither solution is all that elequent. Read about this and by golly, it made a difference

ConcatComments = "'" & CommentString

Before using the CopyFromRecordset be sure to add a single quote in front of the large string.

Turns out the interface between Access and Excel look for this to prepare Excel immediately for the string to be a string, not something else. Some of my strings had weird print characters that kind of looked like Japenese characters. It seemed random, it always happened if the string was 255 or more characters (ramdonly, not always). The single quote doesn't show up in Excel, but got rid of all the noise.

View 5 Replies View Related

Modules & VBA :: Copy Access Data Into Excel Template In Read And Write Mode

Jun 20, 2015

How to open a pre filled excel template in read and write mode from msaccess vba and insert data from msaccess tables into specific columns in excel.

Rename the tabs in excel sheet based on a specific column in the access data.

Each row in the table will go to a seperate tab in excel.

Save the excel template after populating the necessary data into different tabs.

View 3 Replies View Related

Modules & VBA :: Copy Data From Excel Sheet To Access Table And Then Compare Two Tables

Dec 2, 2014

I have a form where when the user clicks on the browse button then excel workbook filepath gets stored in the textbox as below:

Code:
Private Sub CommandButton1_Click()
ChooseFile
End Sub
Sub ChooseFile()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)

[Code] .....

Please see attached the excel workbook. Everytime the user will select Excel workbook using Browse button. Now in that file , the first sheetname will always be "Summary". I want to perform the following steps:

1. So now I want VBA code to copy the data from columns "Withdrawn","Obsolete","Updated","LitRef" from Summary sheet to the Access table named tblSummary.

2. When the data gets copied in Access table then write So VBA code that will check if the data in field LitRef in table "tblSummary" is present in field "Reference" of Access table "tblliterature" . if its present then check in the tblSummary , which corresponding fields out of "Withdrawn","Obsolete" and "Updated" stores "Y" .
3. If "Withdrawn" field value is "Y" then change the status of corresponding record of tblliteraure to "Withdrawn"
4. If "Obsolete" field value is "Y" then change the status of corresponding record of tblliteraure to "Obsolete"
5. If "Updated" field value is "Y" then change the status of corresponding record of tblliteraure to "Updated" .

View 14 Replies View Related

Forms :: Copy Table In Currently Opened MDB File

Jan 8, 2014

How can copy table from another mdb file in current opened mdb file? If copy table is exist in current file table will be replaced.

View 7 Replies View Related







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