Dynamically Creating MS Access Table
Feb 5, 2008
Hi,
I am trying to create a series of MS access tables from within a SQL 2000 DTS package. The names of the tables reflect the date range of the data within them. Creating the "Create table ddmmyy ...." statement isn't a problem (full code below), but doesn't run as it creates a Jet error - "Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'. Does anyone know if what I'm trying to do is possible.
Before anyone suggests it, yes I have posted this on SQL server forums.
declare @TheName char (8)
,@Cmd char (500)
select @TheName = (select max(LastRunDate) from NSP_Analysis_Dates)
select @Cmd = 'CREATE TABLE `NSP_Analysis_' + @TheName + '` (`TYPE` VarChar (200) NULL, `VENDOR_NO` VarChar (10) NULL, `VENDOR_NAME` VarChar (50) NULL, `AMOUNT_CLAIMED` Currency NULL, `REGION` VarChar (100) NULL, `CLUSTER` VarChar (100) NULL, `PLANT_CODE` VarChar (15) NULL, `PLANT_NAME` VarChar (50) NULL, `DATE_OF_SERVICE` DateTime NULL, `STATUS` VarChar (200) NULL, `TICKET_NO` VarChar (20) NULL, `NOTES` VarChar (255) NULL, `DATE_ENTERED` DateTime NULL, `AuthorisedByName` VarChar (50) NULL)'
sp_executesql @Cmd
View Replies
ADVERTISEMENT
Apr 2, 2014
I have an access table and I want the code that will check two columns in the table "EnvelopeType" and "EnvelopeSize" and create headers in Excelsheet automatically. In the attached workbook, like in sheet1 the headers are already appeared, I want this to be done dynamically using vba code so that if new values get inserted in EnvelopeType and EnvelopeSize then we won't have to change the code to display more headers.
Please see attached workbook named Sample and Access table. E.g.
EnvelopeType EnvelopeSize
TNT 2nd Class C5
PP1 2nd Class C5
PPI 1st Class A4
Recorded A4
TNT 2nd Class C5
PP1 2nd Class C5
Recorded A4
PPI 1st Class A4
Recorded C5
With the code it should display following headers in excel sheet:
TNT 2nd Class C5
PP1 2nd Class C5
PPI 1st Class A4
Recorded A4
Recorded C5
View 14 Replies
View Related
May 9, 2006
Hi all,
I write a program which is querying some data from a MS-Access database.
The problem here is, that the tablenames contain characters like "/" or "-" and I
do not want to change these names, because I think that the database
structure will be damaged.
To solve this problem I thought of creating a view to the table. I tried creating
this with a SQL statement, but that did not work.
Is there any other possibilty to create a view on a MS-Access table?
Regards,
Stefan
View 2 Replies
View Related
Jul 21, 2007
I'm experimenting in MS Access VBA reading from one MS Access application to another as visible in the code below. My problem is that I'm reading a recordset from an Access file and want to take that recordset (rec) to create a table in the current databank. If I run an cmd.commandtext "make table query" it runs the query across the connection and places the table in the remote database (as expected). Can I take the recordset and create a local table using ADODB command or is there a better approach. (I should note that the remote MS Access file does not have an .mdb suffix) Thanks in advance.
Sub get_indbyind()
Dim strInputfile As String
Dim dlgOpen As FileDialog
Dim bob As String
bob = Application.CurrentDb.Name
' select connection
Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
With dlgOpen
.AllowMultiSelect = False
.Show
End With
strInputfile = dlgOpen.SelectedItems.Item(1)
' make connection
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
Dim strcnn As String
strcnn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" & strInputfile
cnn.Open strcnn
' MsgBox "connection made"
' create recordset
Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset
rec.Open "SELECT * FROM SATransfers;", cnn
Dim n As Long
Dim i As Long
Do While Not rec.EOF
Debug.Print rec.Fields(0).Value; rec.Fields(1).Value; rec.Fields(2).Value; rec.Fields(3).Value
rec.MoveNext
Loop
' create table from connection cnn
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Dim rs As New ADODB.Recordset
cmd.ActiveConnection = cnn
cmd.CommandText = "SELECT SATransfers * INTO tmp1 FROM SATransfers;"
Set rs = cmd.Execute
cnn.Close
Set cnn = Nothing
Set cmd = Nothing
End Sub
View 2 Replies
View Related
Mar 6, 2008
Hi i hope someome can help. I am importing a data into a table, records are being rejected as they should due to validation rules. However access is not creating a table of rejected records. What am i doing wrong.
Thanks for any help
View 4 Replies
View Related
May 6, 2008
I have currently been given a task to re-work some current coding within Access. This is well above my understanding of Access and was hoping to get a little assistance with some simple coding language.
The database I am manipulating has data collected from tourists about their destinations and origins.
I wish to create 2 tables based on a current table. One table will be short trips (trip length <= 150km) and the other long trips (trip length < 150kms)
I wish for these tables to be created from a table of raw data upon the click of a button (GUI interface).
If you are puzzled by my question. I'll try to make it simplier by asking:
1. what line of code will create a new table overriding old
2. what type of code is required to create this table with specific column headings?
3. How do I import information from current available tables with the condition: 'Row Y' is > X
View 3 Replies
View Related
May 22, 2013
I am trying to create an access table linked to an excel file.
The excel file has 256,000 kb, 15 columns, 6,400 rows.
When I go to CREATE, DESIGN VIEW in access and try to create the new linked access table i get this message -
"MICROSOFT ACCESS HAS ENCOUNTERED A PROBLEM AND NEEDS TO CLOSE". I click on Ok and then it says "REPAIR MY OPEN DATABASE AND RESTART MS ACCESS".
I click on OK and then save the back up file. The file disappears. I start over again and the same process starts again and again...
View 14 Replies
View Related
Oct 30, 2006
I have a pivot table, It is associated with a table in an another database (access database ofcourse!). What I am doing is that I am inserting new data on a click of a button in that table but the pivot table shows the same old data, it does not refresh..!!
How can I do that??
View 5 Replies
View Related
Mar 27, 2014
I have just upgraded from Access 2003 to 2010. Now I'm trying to relearn some of the small things I used to be able to. In 2003, I could just have a table highlighted and select "Insert, Query". It would then open a query design with that table. Is this possible to do this in 2010? Or do you have to open query design then add the table manually?
View 2 Replies
View Related
Oct 14, 2005
Hi.
Is there a way to set the record source of a textbox control from an access report to something else then a field from a table or query ? I didn't found one.
I wanna to display in a report some processed and parsed data from a memo field (the processing and parsing is done in a function from a module). In the report, I wan't to display this data, BUT can't, because the only dinamically value that can be changed to a textbox is record source (I cannot change it's value when the reports opens), and the data processed isn't stored anywhere in a table ... so ... I'm stuck. I've also tried to display the data in report in a label (not in a textbox) and dynamically resize the label, but at some point, I riched the maximum label height :((
Is there a way to do this ???
Thanks,
Mihai.
View 1 Replies
View Related
Apr 23, 2015
I am currently working on a Database to automatize some process.
The User can import a CSV (Text) File via a DialogBox, which gets imported into a Table. After this, the content has to be filtered, setting conditions on 4 different rows. The new Table gets exported into a new CSV (It has to be CSV, since it later gets imported into SAP)
How can I set a Filter on a dynamically created Table (using VBA)?
Best case would be to save the filter into my Import spec, but Access doesn't seem to have this option (?)
View 3 Replies
View Related
Apr 7, 2014
I have several lookup tables in an Access database. These tables are used to populate fields in the main table and act as filters for viewing record subsets.I want to create a form that does the following:
1.) List the lookup table via a combobox.I was able to accomplish this with the following code:
Code:
SELECT MSysObjects.Name AS [Table Name]
FROM MSysObjects
WHERE (((MSysObjects.Name) Like "tblJob*") AND ((MSysObjects.Type)=1) AND ((MSysObjects.Flags)=0))
ORDER BY MSysObjects.Name;
2.) When a table is selected from the combobox, display the table in a subform for updating.
View 7 Replies
View Related
Feb 13, 2007
Hello,
My requirement is this...
I have to use MS Access as front end with ODBC connection to Oracle 9i
DB.
The application(forms) should be able to update, delete ,insert records into oracle tables(backend).
i have a main form,which has some unique id's and other info about the ids and the subform shows several matching id's for that unique id in main form. the user who uses this application should be able to
1) search for the unique id in the main form such that the subform displays all its matches
2) they should be able to select anyone match and say approve(there can only be one match), then that particular record should be updated in the table.IF I USE A CHECK BOX AND IF THEY CLICK ON ONE RECORD AS MATCH,HOW
DO I TAKE THAT RECORD SAY THE ID , NAME ADDRESS AND ALL DETAILS AND UPDATE THE TABLE???
similarly when they select some other record i should give option of deleting other irrelevant matches in the backend table.
the main form and the subform uses the same table as source.updates are to another table, i should also have to put entry into audit table about which record was deleted and which one inserted..
How should i do this?? i am new to MS access .VBA, any help would be highly appreciated!
Thanks so much!
View 1 Replies
View Related
Jun 28, 2013
I must use XP/Access 2003 to solve this problem for reasons I won't get into.
I have a report with a Group by on City.
The users need to be able to sort by Coordinator within that OR by Client Name based on a selection they make on the form that opens the report.
-- I have tried to set .OrderBy
-- I have tried to set .RecordSource to different queries with order by hardcoded in them (I only have 2 sort options fortunately)
Is there a way to dynamically change the "Sorting and Grouping" defined in the report? This seems to be the only sorting that the report is responding to.
View 1 Replies
View Related
Sep 13, 2007
Hello all,
I have a temporary table with Yes/No fields (F101,F102,F103,....etc).
In another table i have a field called ProductCode with values (101,102,103,....etc)
Is it possible to append(or update) the records of the temp table with criteria on "F" &ProductCode field? (For example if ProductCode=101 then F101 sets to yes)
Thank you in advance.
View 4 Replies
View Related
Apr 18, 2013
I have developed a database using Access 2010. This is split into a Front End and a Back End.
In the same folder as the Back End I store a number of user modifiable files in either bitmap (.bmp) or MS Word (.doc to retain compatibility with older versions).
Unfortunately, the drive letter where the back end resides will change from location to location and I can't do anything about that.
I have set up a function that returns the location of the folder where the docs reside irrespective of the back end drive location, and this works perfectly with OLE linked pictures but not with OLE linked Word documents. User changes show correctly in Word document changes at locations with the original drive assignment but other locations show only the original doc contents even though they have been changed on the local back end location. - even if I delete the Source Item info on the report!!
An example of the code I am using for the Source Item is <GetBackEndPath() & "Footer.doc"> without the angled brackets of course, where GetBackEndPath() is a global variable storing the location of the documents folder ending with a back slash.
I have tried the above in the reports Source Doc property but Access won't accept this and says it isn't valid for this property.
View 2 Replies
View Related
Oct 10, 2007
Hi all,
I have a text source file and inpul layout i.e. field names start and end positions in excel file. I want create a table in access from the text data using excel file layout.
Can you please help me out in this. I am a mainframe programer and recieved an request to work in access.
View 1 Replies
View Related
Sep 14, 2005
How do I create a table that can cross index items in another table. Maybe I am not using the right terms here so let me show a small example.
Say I have a tables of words.
tblWords
numWordID
txtWord
Then I have some entries, all more or less synonyms of each others
fresh
new
clean
Now I want to create a cross-index table, related to the table "tblWords" where I can select synonyms from words already in the table "tblWords", so if I for the word "fresh" add "new" and "clean" as synonyms or entries, if I then go and look at the word "new" it will already have the synonyms "fresh" and "clean", likewise the entry "clean" will then have the synonyms "fresh" and "new".
Kind of a many to many relationship junction table but only with one table!
I hope my explanation have not been to confusing, but let me know if you need a clarification.
Thanks
View 6 Replies
View Related
Oct 9, 2006
Hi,
I have created an Access Form wherein i take the user input in various text boxs and text areas.
Now plz help me to find out how to create Microsoft Word Document automatically from the information which the user has submitted.
I have provided a button named submit which when clicked will submit the information into the Access Database and using that data i want to create a Word Document into a particular format.
What is the way in which this could be achieved?
Please help me out to find a solution to this problem.
Thanking you,
with regards,
Kapil
View 12 Replies
View Related
Jul 25, 2006
Hi,
I ve got an access db thats attached to a java application.
I need to be able to create a temporary table that stores a result set, its necessary to do this as the java app needs to perform lots of repeated operations on this temp table.
I was think something like this would work:
DROP TABLE tempResults
CREATE TABLE tempResults
AS
SELECT col1, col2, col3 ....
FROM orginalTable
So i tried this:
Create table temptable AS
SELECT education,
FROM supermarketTable;
but it doesnt work, access complains about syntax error in create statment.
Could anyone give me some pointers?
thanks in advance!
View 2 Replies
View Related
Apr 2, 2007
what i am trying to do is have something create a new table. It could either be when a check box is clicked. but preferably when a name is entered into a text box. i just need the sub command to write. i tried using what access help has: SyntaxCREATE [TEMPORARY] TABLE table (field1 type [(size)] [NOT NULL] [WITH COMPRESSION | WITH COMP] [index1] [, field2 type [(size)] [NOT NULL] [index2] [, ...]] [, CONSTRAINT multifieldindex [, ...]])The CREATE TABLE statement has these parts:Part Description table The name of the table to be created. field1, field2 The name of field or fields to be created in the new table. You must create at least one field. type The data type of field in the new table. size The field size in characters (Text and Binary fields only). index1, index2 A CONSTRAINT clause defining a single-field index. multifieldindex A CONSTRAINT clause defining a multiple-field index but i keep getting an error. if someone could just give me a sample code that i could copy and paste into the code builder to get a simple table with one or 2 coloums i could edit to the specific things i need. i just dont know where to start. thanks for the help.
View 1 Replies
View Related
Apr 25, 2006
Hello everyone!
I heard from a number of people that this is the place to come for Microsoft Access related help.
So here is my question and I hope someone can help me understand access a little bit better.
I am trying to create a database for a job I am doing. THere are 700+ convenience stores that we (4 inspectors) inspect every three months.
We have been told to do an ADA compliance survey when we visit these stores.
The ADA checklist that we have is about 78 questions and my manager wants me to create an ADA database for this information.
So I am in need of help on how to create a database that allows me to input the answers of this ADA checklist for each store inspected.
I then would like to be able to pull all that information into a report that I could say of the 700+ stores, 50% passed all questions, 25% passed only questions 1-??, etc. etc.
I can upload the two files: The ADA checklist and our Store list if anyone would like to help me out!
Thanks Much!
View 9 Replies
View Related
May 11, 2006
hello :)
how can i create a view in access? is it possible using any of the wizards or can i even use the sql coding feature??
is it possible to grant views to users???
View 2 Replies
View Related
Apr 2, 2008
Iam new to access and having problems create database tables and their relationships, from the following details without duplication.
Tape Identification Numberà unique tape identity
Date -à the date the backup is done .
Backup type à either Daily or weekly or monthly or Full System or Yearly or Special
Duration à either automatic or Manual
Technician name à Person performing the Backup
Comment à comments about the Tape’s history
Location à tape is either located onsite or offsite.
Number of use à Number of times the tape has been used
Restoration à tapes restoration Details, either yes/no
Requirements
1.perform backup everyday
2.Perform restoration everyday
3.Search for tape from offsite storage
a.Tape should be located offsite
b.If it was used for daily backup, it should be at least 60 days old from current date.
c.If it was used for Weekly backup, it should be at least 6 months old.
d.If it was used for any other backup type, do not use.
** the database should provide history
View 1 Replies
View Related
Nov 4, 2004
I am working with some chemical compounds in a database I am building. I grabbed an html file off the web on a listing of chemical compounds...converted it to ascii and imported it into ACCESS. Rather than write a Perl routine I was wondering if anyone out there had some sql code that might handle it. The first 3 records look like this and are contained in one field. I am trying to break this guy into 4 fields.
0001 Acetaldehyde 75-07-0 AB1925000
0002 Acetic acid 64-19-7 AF1225000
003 Acetic annhydride 108-24-7 AK1925000
The fields would be named in order as:
GUIDE 002
CHEMICAL_NAME Acetic acid
CAS_NO 64-19-7
RTECS_NO AF1225000
The first two fields are left justified but the number fields are rather zigzagged throughout.
Anyone have a cure for this beast?
I thank you in advance.
the raven man.
View 8 Replies
View Related
Mar 1, 2012
at the moment we have been given this problem where we have to incoporate a Dmax function into the following code
IDnumber = Left(Firstname, 3) + Left(Lastname, 2)
from this code the ID number creates something that looks like this
gembl
however i need a four digit number after this ID, for every different ID i need the numbers to increase by one the following code was given to us to do in Got Focus but this did not work
IDnumber = Left(Firstname, 3) + Left(Lastname, 2) + Trim(Str(DMax("right(IDnumber,4)","Customer tbl")+1))
View 3 Replies
View Related