Modules & VBA :: Renaming Tables With Spaces In Name
Sep 30, 2013
I am developing code to trawl through the tables in a large number of databases that I am working on for a client and rename tables that have spaces in the name.
I tried using the following but get a 7874 error when the new table cannot be found.
DoCmd.Rename strExistingName, acTable, strNewName
I then tried copying the table using the following but get the same error message.
I understand the principle of renaming the above of using the navigation pane and selecting the object but what is happening in my case is that when I select the specific table/query I wish to rename, the text is highlighted as per normal but the instant I move the cursor onto that cell that whole panel highlights in red and then reverts back to the original state of just the text in that panel (now highlighted).
I do not know if this is related to the problem but I have a text box with the "code" =Count([tblEntries].[CageNo]).
This was working perfectly okay but both this and the renaming appeared to happen about the same time. I have opened other Access files and the same re the renaming occurs. I have secure security running and do not think this could be the problem but anything is possible.
I am playing around with a sample Access 2007 database that has a number of tables, forms, reports queries and macros.I would like to rename then so that the names make it easier for me to recognise what they are when listed in a drop down list.
For example, I have a form named "Workorder Parts" and a table named "Workorder Parts" and I would like to rename the table to "tWorkorder Parts" and the forms to "fWorkorder Parts".I am assuming that these are referenced throughout the database and would like to know if there is a simple way to do a rename on mass?
Code to rename photos (Access 2010). The new name (full path) is listed on a table (although I would love to accomplish the task from the list query that I later used to generate the table). There is one field in the table (or query) called OldPath and one field called NewPath. The table name is RenPaths. Both paths are located in the same drive. I want to rename the file in a new folder. I created the new folder which is contained in the NewPath.
I was trying to accomplish this using the Name function
Name OldPath as NewPath
Here is the full code:
Private Sub Command0_Click() Dim rs As DAO.Recordset Dim db As DAO.Database Dim OldPath As String Dim NewPath As String OldPath = "Select OldPath From RenPaths"
[Code] ....
Here is an example of the paths in my table:
Old Path is - C:UserskcrespoDocumentsFulcrum to MACPFulcrum_Export_a97dee97-ba92-455e-9d5c-3b35617ad357SAA Inspection Form367e14e0-439b-4a50-99e1-9154bcc9e3f7.jpg
New Path is - C:UserskcrespoDocumentsFulcrum to MACPFulcrum_Export_a97dee97-ba92-455e-9d5c-3b35617ad357SAA Inspection FormimageswwMH51856_A3f7.jpg
Im getting an error: Run time error '53': File not found
I checked the OldPath and everything is correct so if the code is working correctly it should have found the file.
I haven't used FSO before, and it seems that the syntax is a little different than typical VBA for strings, but I can't quite figure out what I'm doing wrong here... I keep getting a "file not found" error on the "FSO.CopyFile..." line. I have printed all of my strings to the immediate window to check that they're printing correctly. It all looks good. My code is as follows:
'Copy file 'Set up strings for coding file names Dim FilePath As String FilePath = Me.txt_FilePath Dim FileName As String FileName = Me.txt_FileName
I have an Access DB with hundres of queries and reports, now I have to use an external DB (Oracle) and export data keeping the rest, no problem with that, I have added linked tables through odbc and works fine.
My problem is that some of the tables have field names with spaces, and Oracle doesn't admit them. Does anybody knows how to solve it without having to modify all the queries, etc?, I've been thinking about aliases or views over the linked table but I haven't found a way to create these.
I'm working on an eBay uploader access program for Ebay's File Manager
Our description contains line feeds and carriage returns. I have very little knowledge of Vba, and I can t find any tutorials on how to replace the characters with spaces on how to program this.
The table is called tblCustomer The field is called *Description
I'm trying to improve the dialer that i place on microsoft access forms. basically there's a command button that dials the number that is in a text box, but we have a new job that's just come in that requires numbers to be copied and pasted into the text box. these numbers have a space between the dialing code and the telephone number and i need to make the dialer check for a space and remove it before dialing.
Here's the code for the dialing buttons:-
Private Sub cmd_Dial_Click() On Error GoTo Err_cmd_dial_Click CT.MakeCall "8" & txt_telephone.Value & "#", "", False, "", "", False
I am in trouble with the shell ocmmand,i have a text box "ExcelPath Location" in which there is a path of excel file i am using below code to open the excel file but it gives an error:
Code:
Private Sub Command11_Click() Dim str As String str = ExcelPathLocation.Value strPath = Dir(str) Shell "excel.exe" & """" & strPath & """", vbNormalFocus End Sub
In Access 2003 when you rename a table any queries that the table is in will be renamed aswell, which is usually very useful.
However, is there a way to turn this property off, because I am trying to run over a hundred of the same query that use different tables? In Access 2000 I renamed the tables and used the same query, because it is much quicker, but I have just noticed that the data I am extracting is inaccurate, because when I undo the rename, the table names change in the query.
I have built a fairly large access database (office 2003) and unfortunately I was a bit careless about naming my controls and macros. I would like to go back over all of my form controls and macros so that they have more descriptive names, but I'm afraid this will break alot of dependencies. How can I have the macros autoupdate to compensate for renamed controls and vice versa?
This is a strange one. I have a VERY simple query that runs directly off a single table which contains about 7 fields and one PK. I am pulling through 4 columns from this table including the primary key. I am renaming the columns using the format "NewName: Record_Id" format. I have also tried changing the caption on the query column properties. Basically, the problem is that I save and close the working query but when I either close the database down or make a change to another form or query, the column names all get changed to a single value of the table, currently "Report Title". When the query is run, all the columns are shown with the same header name and the data results are all the same. I have checked my relationships and they are fine and I have also done a compact/repair but without any luck. Can anyone please help me?
i have four oracle db'ses mydb_db_test, mydb_db_production, mydb_db_develop
within access i have linked tables from the first one; let's say: mydb_db_test.tblOne, mydb_db_test.tblTwo
What i want to do is: 1) import the same tables from the other trhee db'ses 2) rename the table names by vba code example: my_db_db_test.tblOne has to become tblOne and when i switch from db (to for example the production), the tblOne has to be renamed originally (mydb_db_test.tblOne) and the other has to be renamed (so mydb_db_production.tblOne becomes tblOne).
Now the question which you probably ask me: Why not by a connection string change...
Well, that's the problem, the linked tables are being set to readonly, and the property cannot be changed (at least, as far as i tried); so that's why i thought of this workaround. By linking all three databases, i also always have for those table the three connection strings, and by renaming them (i now do this manually) i always can pick the right connection.
I have a table Client-Details,in which i have a record namely "bharti-chennai".this table is associated with aother table "release-details". bharti-chennai has records in relase details.i want to change the name of bharti-chennai to bharti -mumbai ..how to do it.
I am trying to email a report and rename the report after the referenced NCR# currently selected on my form. My codes works for putting the referenced NCR# in my email subject, but I am having issues renaming the report and the error is with the SetProperty line bolded below. When I click my email button, I get Run-time error 32004: The control name "Supplier Chargebacks" is misspelled or refers to a control that doesn't exists.
Private Sub Command587_Click() Dim stReport As String Dim stWhere As String Dim stSubject As String Dim NCRNum As String NCRNum = Forms![NCR Input Form]![NCR #]
I want to automate a find and replace process to standardize names in a table, using the value from one table to replace another. The code I have is not quite working.
Background: - Table [Checking] field [Description] has the source text field that I like to change/standardize - Table [Rename] field [Description] has the text string used to search the [Checking].[Description] values. The search should contain wildcard logic so e.g. a [Rename].[Description] value of "Mobil" would find a [Checking].[Description] value of "Mobil 123", or "Mobil 234", or "Mobil123456 AB". - Table [Rename] field [NewDescription] is the new value used. If [NewDescription] = "Mobilx", then the "Mobil 123", or "Mobil 234", or "Mobil123456 AB" would all be changed to "Mobilx".
I have the following code which partially works:
UPDATE checking, rename SET [Checking].[Description] = [Rename].[NewDescription] WHERE ((([Checking].[Description]) like "*" & [Rename].[Description] &"*") );
Problem is the original [Checking].[Description] value is not deleted in full so the replacement [Checking].[NewDescription] value is not correct.
e.g. "Mobil12345 AB" might be changed to "Mobilx AB" instead of "Mobilx" (some of the original string remains).
This works but how do I use "datecreated" to get the creation date of the table and format it. I tried to use DateCreated in place of Date but get errors such as variable not defined or .datecreated without a with block.The result I'm going for is something like "tblMstr20140603".
I am in the process of developing a pivot table with grouping per month per year which works just fine. However, I would like to rename the column header items. It will not allow me.
The scenario: the data is from a query that deprives data from two tables (Date from Table A) and (TypeID from Table B: Query will show TypeID in text format based on SELECT to show data in text format not numeric format).
The struggle: Renaming the column headers which shows the TypeID in numbers based on its ID (the first column of Table B), not its Description (the second column of the Table B).
The question: How do I make the column headers to show the TypeID in text based on its Description in the second column of the Table B?
I have a database that is saved as an accdr so it can be compiled for distribution as an exe..I have just found the accdr the exe installed and renamed to accrb and was then able to open it and view all the tables, forms etc.Obviously I cant stop someone renaming but if there was a way to stop the forms, tables etc opening.
I have a table w/field set as text that I don't want users to enter a "space" into, how would I stop this? I suspect " " in the field validation field? Does this sould correct? What does everyone else use?
Hi, I have a text box in a from for data entry, how do I disable a space. For example I don't want the user to have a space between charaters or before and after a charater. Thanks.
As part of an extraction program I'm making, I've got a table (lets call it TABLE1) with values that have trailing spaces e.g. "ENGINEERING ", "LOGISTICS ", etc....
This has been set up as such to match the values that exist in a read only table I am linking to from another database.
I have used a query of TABLE1 as a row source for a combo box. When the values are selected in the combo box the trailing spaces are lost.
i want to replace spaces in my query, but there are a few hard parts in it. I dont always know how many spaces. en second, the spaces that need to be replaced are after the first character. The rest needs to be removed.
i have: ----1----1----2
the "-" are spaces!! and i want it to show 1.1.2
this is what i tried replace([MinutesID];" ";".") & " - " & [minutesTitle]