Create Table DDL Statement

Jan 26, 2008

Hi,
I am writing ddl statement for creating tables in access, i would need to provide a default date for a date column, how can i do this in a ddl statement ?

In the table design window in the gui, i can do it by providing the default as "=format(now())" but it seems not to work in the ddl statement.

also, is it possible to generate the ddl sql statement for an existing table in the database, i would need to know how can this be done too.

Thanks for the help
Joy

View Replies


ADVERTISEMENT

Creating SQL Statement To Create Table

Apr 19, 2007

Hey all

I have an online Access database and dont want to have to take it offline (download, update, upload) to create a new table.

Therefore I want to use a CREATE statement that I can run via an ASP page to create any additional tables.

I don't want to have to create the statements by hand so im looking for a way to create a table on my local version of access and export the SQL statement that would be used to create this table.

Any idea?

Thanks

View 1 Replies View Related

Validation Rules In CREATE TABLE Statement

Oct 9, 2007

Hi, I'm fairly new to Access and I'm trying to figure out how to create a validation rule via SQL. I searched through the forums but didn't find anything. Hope someone can point me in the right direction. For simplicity say I have the following extremely simple CREATE STATEMENT.

CREATE TABLE GAMES (
Name TEXT PRIMARY KEY NOT NULL,
Amount CURRENCY NOT NULL,
);

How could I rewrite the above query to specify that the only valid amounts allowed are say between 1 and 10?
I'm familiar with the Constraint statement and the Check clause but I can't get these to work in Access.

View 2 Replies View Related

Create Table Statement Syntax Error In Access 2000

Aug 7, 2005

Hi guys i tried to run this create table statement and each time i get syntax error.
I pasted the code in sql view windows of access 2000 and pressed the run code and i get
this error massage saying there is syntax error. Could any one help me write correct
create table statement that does not give me this error.I know u might tell me why u
do not create table in design view or .. but i want to do this since i want learn this
method as well.thanks



CREATE TABLE PLAYERS
(PLAYERNO SMALLINT NOT NULL CHECK (PLAYERNO >0),
NAME CHAR(25) NOT NULL ,
INITIALS CHAR(5) NOT NULL ,
BIRTH_DATE DATETIME,
SEX CHAR(1) NOT NULL ,
JOINED SMALLINT CHECK (JOINED >=1980),
STREET CHAR(15) NOT NULL ,
HOUSENO CHAR(4),
POSTCODE CHAR(6),
TOWN CHAR(10) NOT NULL ,
PHONENO CHAR(10),
LEAGUENO CHAR(4),
PRIMARY KEY (PLAYERNO)
)

View 1 Replies View Related

What Is The Syntax Of Create Table And Insert Statement For Access 2000 Db.

Jun 26, 2005

What is the syntax of create table and insert statement for access 2000 db.

I want to paste the create table and insert statement to access 2000 "sql view window".
Therefore i want the correct syntax and format for these statements.
The reason that i want do this is that I created an application that generates create
table and insert statements for access db in text file and this way i want to test my application if it
generated the statement correctly.

View 3 Replies View Related

Create Table Statement Syntax Error In Access 2000

Aug 8, 2005

Hi guys i tried to run this create table statement and each time i get syntax error.
I pasted the code in sql view windows of access 2000 and pressed the run code and i get
this error massage saying there is syntax error. Could any one help me write correct
create table statement that does not give me this error.I know u might tell me why u
do not create table in design view or .. but i want to do this since i want learn this
method as well.thanks


Code:CREATE TABLE PLAYERS(PLAYERNO SMALLINT NOT NULL CHECK (PLAYERNO >0),NAME CHAR(25) NOT NULL ,INITIALS CHAR(5) NOT NULL ,BIRTH_DATE DATETIME,SEX CHAR(1) NOT NULL ,JOINED SMALLINT CHECK (JOINED >=1980),STREET CHAR(15) NOT NULL ,HOUSENO CHAR(4),POSTCODE CHAR(6),TOWN CHAR(10) NOT NULL ,PHONENO CHAR(10),LEAGUENO CHAR(4),PRIMARY KEY (PLAYERNO))

View 1 Replies View Related

How To Create Conditional Statement

Sep 6, 2005

I guess I need to create an if else statement for one of my fields in a query. The query basically calculates a dollar amount from certain fields in one of my tables and sums them together at the end with an expression.

I also have a true/false field in the same table. and if it's true then the expression in my query must equal 0, if false then it sum up the fields. Do I need to create a module for this or is it possible to do this directly in query? And if so, how?

Thanks,

View 2 Replies View Related

What's Wrong With This Create Statement? (Urgent)

Jan 10, 2006

CREATE TABLE Jobs
(jobname LONGTEXT(1000) NOT NULL, [desc] LONGTEXT(1000) NOT NULL,
[req] LONGTEXT(1000) NOT NULL, [specialreq] LONGTEXT(1000) NOT NULL)

Thanks!

View 1 Replies View Related

Queries :: Create A Query Dynamically From Vba Using A CreateQueryDef Statement?

Nov 19, 2013

I can create a select query with a combo box in it by changing the property of one of the fields - making the display control to combo box and adding the values. No problem there.

What I want to do is to be able to create a query dynamically from vba using a CreateQueryDef statement.

The problem is that you can only pass an SQL string to CreateQueryDef, and the combo box values are not part of the SQL code, but are saved with the query (presumably the same way column layout gets saved).

Is there a way to create a query with VBA and include non-SQL layout criteria so I can have combo boxes?

I'm using Access 2002.

View 6 Replies View Related

Forms :: Create A Button That Executes SQL Statement In A Form

Apr 24, 2013

I want to create a button that executes an SQL statement in a form. The reason I can't just save a query and run the query from the form, is because the SQL statement needs to use a combobox value from the form. I've learned that docmd.runsql will not work for a simple select query.

View 5 Replies View Related

Modules & VBA :: Create Disable Alphabetic Keys Function Based On Case Statement

Jul 31, 2015

Details:
I have a Profile form that tracks the expiration date for each client's various certifications. These dates are set up in the Short Date format in the table design of Access.

Problem:
When a user accidentally presses an alphabetic key while updating an expiration date, an Access error message is triggered. This is confusing to my users as these messages are written in Access lingo. I would rather that nothing occurs at all. I wrote a case statement to disable each letter of the alphabet and applied it to the On Key Down Event for each expiration date control on my Profile form to solve this problem, but this must be applied to 28 separate controls. I would rather call a function that disables alphabetic keys for each date control in my form when called.

Questions:
How do I transform my Disable Alphabetic Keys Case Statement into a function that I can call for each expiration date control? I know that when writing a function certain variables have to be declared and/or initialized.

Also, will I need to create a function to re-enable alphabetic keys or is this unnecessary because the disable alpha keys function will only be called for specific controls, not the entire form?

What I Have Tried:
I have tried copying and pasting my Disable Alphabetic Keys Case Statement into a module to attempt to create a function, but it needs work.

Below I have included 2 types of code:
(1) The original On Key Down code applied to each date control on my form
(2) The same code written as an attempt at a function

Original Profile Form Code to Disable Alphabetic Keys in the On Key Down event for each date control

Private Sub txtCert1ExpDate_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
'All message box text is for me to test the code, not for the user to see
Case vbKeyA
MsgBox ("you pressed the A key")

[Code] .....

View 14 Replies View Related

Queries :: IIF Statement Expression - Create Alias Column Based On Data From Two Fields

Jun 20, 2013

I am writing a very complex 'if statement' query expression. I need to create an alias column based on data from two data fields.

Here's the logic:

True: If [PP] = "WG" or "WS" or "WL" and If [GR] > 10 Then "Skilled" or
[GR] Between 6-9 Then "Semi - Skilled" or [GR] <6 Then "Unskilled"

False: "GS"

View 2 Replies View Related

Tables :: Pull Field From Main Table And Create A New Table With Date Stamp

Nov 4, 2014

I have a make-table query that pulls all the fields from 1 table (MainTable), and creates a new table with a date stamp based apon a form value entered (New Table = MainTableWithDate).

Currently, I setup the query to pull info from the form field like this:

DateField: [Forms]![frmmain]![DateField]

However, when the make-table query is done - all date fields are blank (all other fields are correctly created), and when I look at the new created table (mainTableWIthDate), the typeassigned to the date field is "Binary" (in the form, I've specified LongDate).

View 6 Replies View Related

Create Table Of Different Columns In Three Tables Join To Form A Master Table?

Jun 4, 2015

I have three tables that contain different columns but linked by a primary column call Name. I want to create a table where all these different columns in the three tables join to form a master table which can be updated regularly either through the master table or the smaller tables. The master table also has the primary column as Name.

If I update the master table with records, it should update the respective linked table and vice versa. I also want to link these tables to my SharePoint site.

Note: except the Name column, none of these tables have any other columns in common How do I go about this?

View 7 Replies View Related

Create Duplicate Table Using Same Form And Compare It With Original Table

May 1, 2012

Here is what I am trying to do: I have form, and a table which is created from this form. The data is entered a second time using the form to make sure there are no discrepancies.

Any easiest way to implement this? (create a new table (which is duplicate), and then compare them?

View 5 Replies View Related

If Statement In Table

Oct 31, 2007

Hello:

I'm working on a class assignment and I am in desperate need of help. I am trying to set up a table... the fields are as shown: Type of Registrant, Registration Fee, Number...

I've created another table that has a list of names, telephone numbers, amounts paid, and registration status...

I'm creating the table I talked about in the first paragraph to simply list the status of registration, the amount per registration status, and the total number of registrants per status...

The available registration types are as follows: Academic ($285), Student ($200), Executive ($300), Manager ($225)

What I would like is this: When entering my information in this new table, I would like for the registration fee to automatically appear... almost like a set value... So, if I entered "Academic" in the "Registration Type" field, the amount $285 would automatically appear. I've tried a few "if" statements, and they're not working in my favor... Is there any kind of code that will allow this to happen? Please keep in mind, the reigstration types from which the information would be pulled are in the form of a list box in another table... Thanks!

View 3 Replies View Related

General :: Can Create Extra Sub Table Under Sub Table Already Created

Jul 19, 2012

I have two tables. The first one is as follows:

MP No (Primary key), Sales, Date Entry, Specs, Email

The second Table is as follows:

MP No, Quantity, Description, DWG, Price

There is a "one-to-many" relationship between the two tables through the MP No field so whenever I go to the first table there is a sub-table for each MP No. Correct?can I create an extra sub table under the sub table already created?

View 10 Replies View Related

Creating An If Statement In A Table

Jun 6, 2007

I have created a database that tracks employee adherence. We have employees monitor adherence and when someone is out of adherence we track the time they are out and also there shift time. I am needing Access to know to change a record from 0:00 (midnight) to 23:59. I know it is probably done with an IF statement but dont know how to write it correctly, or where to place it.

View 1 Replies View Related

Default IIF Statement In A Table

Dec 28, 2005

I am making a default value statement in a table that looks like this
IIF([company name] IN(“name1”, “name2”, “name3”), Date()+14, Date()+30);

this statement says that if the companys name is any of the names in the list, then the date outputed will be todays date +14, otherwise, the date will be todays date +30.

whenever i try to use the statement, access keeps giving me the error...
"you omitted an operand or operator, you entered an inalid character or comma, or you entered text without surrounding it in quotation marks"

what is wrong with my statement??

View 5 Replies View Related

Queries :: Using The Value Of Table Row In A Like Statement?

Oct 22, 2014

Is it possible to use a value of a table row in a "Like" statement of a query ? Below is query code that I want to modify to accomplish what I need. I want to search the "BudgetIn (Description) table for records that are like "ExpensesIn (Accounts) - table. I thought that if I entered the value in the "EXpensesIn" (Accounts) table, surrounding by asterisks, would give me what I needed. Unfortunately, the query criteria placed quotes around the critrea and the query looked for text (i.e. "*[ExpensesIn]Accounts*") rather than the value in the table.

SELECT BudgetIn.Description, ExpensesIn.Expenses, BudgetIn.Previous_Budget, BudgetIn.Budget_Year, ExpensesIn.Accounts
FROM BudgetIn LEFT JOIN ExpensesIn ON BudgetIn.Description = ExpensesIn.Accounts
WHERE BudgetIn.Description Like *[ExpensesIn]Accounts*;

View 5 Replies View Related

Exporting The Results Of A SQL Statement Into A Table

Oct 10, 2005

I am going to attempt to explain the problem:

I design a form and all my work is based on that form.
I have two tables which I join together as following.
The unfitex field is calculating using fields from both tables as shown below.

Dim db As Database
Dim rst As DAO.Recordset
Dim sqlstr As String
v = Combo37.Value
sqlstr = "SELECT postdecgor.N1, postdecgor.Age, postdecgor.UNFITpc, postdecgor.DECENTpc, postdecgor.HHSRSpc, [UNFITpc]*[sample]/100 AS UNFITex, postdecgor.DECENTex, postdecgor.HHSRSex, [Sample size].[Age dwelling], [Sample size].sample FROM postdecgor LEFT JOIN [Sample size] ON postdecgor.Age=[Sample size].[Age dwelling]WHERE ((postdecgor.N1)='" & v & "'); "
Set rst = db.OpenRecordset(sqlstr, dbOpenDynaset)
Set Form.Recordset = rst

I then set up some textbox which shows the results as following.

N1.ControlSource = "N1"
Age.ControlSource = "age"
UNFITpc.ControlSource = "unfitpc"
DECENTpc.ControlSource = "decentpc"
HHSRSpc.ControlSource = "HHSRSpc"
UNFITex.ControlSource = "numunfit"
UNFITex.ControlSource = "unfitex"
DECENTex.ControlSource = "decentex"
HHSRSex.ControlSource = "HHSRSex"

It works, I can see the results on the screen, however I would like to save the results into a table and I am not quite sure how to go about it.
Can you help??

Thanks for your help

View 1 Replies View Related

Using Info From One Table In The LIKE Statement Of A Query

May 17, 2007

Is it possible to construct a query that uses information from one table to run a series of Like OR Like... criteria?

I have created a table that contains partial part numbers and would like to query a second table for all the part numbers that contain these partial part numbers.

Meaning, BACB30DX6 would return the desired information for BACB30DX6-7, BACB30DX6-8 and so on.

The TBL_PARTS_FAM_DIA table contains approx. 200 items so 200 LIKE statements can't be the way to go... I'm hoping.

I tried: LIKE "*[TBL_PARTS_FAM_DIA]![PARTS_FAM_DIA] *" thinking that perhaps this would go through all 200 items... but of course that was wishful thinking.

Do I really need 200 LIKE statements or is there some easier way to do this.

Thanks in advance!

View 2 Replies View Related

Multiple If Numberic Statement From A Table

Jul 20, 2006

I have tried searching and haven't found an answer to this question.

I have a calculated field in a query that returns a aging date to an invoice. I want to take that aging date and apply it to a multiple If statement. I tried a joining field, but it's not working. A simple multiple If statement should do the trick though.

If AR is:
0-10
Then return:
"Current AR"

If AR is:
11-40
Then return:
"001-030"

If AR is:
41-70
Then return:
"061-090"

There are more, but I can figure that part out once these are solved. Any help would be appreciated.

Thanks,
Jason

View 3 Replies View Related

Queries :: IIF Statement Only Picking Up First Value From Table

Jun 10, 2013

I have a table of rates based on ages and I am doing a query that will calculate your rate based on your age. I am using the IIf statement like this:

EERate:IIF([EEAge]>25,.345,IIF([EEAGE]>30,.425,.3)

The query will only use the first rate even if age is above 30.

View 3 Replies View Related

Create Table From Truncated Info From Other Table

Oct 20, 2006

I'm a relative newbie to the more advanced features available to Access.

If someone could help me or point me in the right direction, I'd really appreciate it.

I have one table that contains companies and associated contact info. Each company can have more than one unique number ID (3 digit alphanumeric).

I want to take this table and run a query to create a new table that will only have one instance of each company name, along with the other contact information. The unique ID's aren't needed in this table (but it would be great if I could somehow toss them in, too).

This new table would then be used to create a form with a combo box containing all of the names to quickly jump to their contact info.

Any and all help would be appreciated. If a query isn't the best avenue for this, then please point me in that direction, too.

Thanks!

View 5 Replies View Related

Using Data In One Table To Create Fields In A New Table

Dec 7, 2006

Hi there :)

I'm not sure if I've picked the right forum topic for this... It's not a straightforward table question, and I think the only way I can do what I need is with a query of some sort. Apologies if it should have gone in 'Tables'...

The situation is: I'm creating a database (using Access 2003) in which our secretaries can enter exam marks for students. The difficulty is that there are ten papers (exams), each student's exam is marked by at least two examiners and there are at least 6 examiners per paper. Every examiner also marks more than one paper, but doesn't mark all papers.

So, I've got a table with all of the examiners and the papers they're marking and I've got a table with all the students and the papers they're taking. Because we have to enter the marks in such a way that we know both which mark an examiner gave and (obviously) which mark a student received (e.g. so we can look at statistics for each examiner), I thought the best way to do this would be to run a query that created a new table per paper in which the field names would be: Student_ID, <name of examiner 1 for the paper>, <name of examiner 2 for the paper>, <name of examiner 3 for the paper>, etc until the end of the list of examiners for that paper. The student's number would populate the Student_ID field and then the secretaries would enter each examiner's mark in their named field. Like this:


| Student_ID | A.N. Other | J. Blogs | J.Q. Public | Agreed_Mark |
1234A 72 74 73
2345B 65 68 67
3456C 71 73 72
4567D 52 51 52



Listing the name of every examiner (including those who aren't marking that particular paper) isn't an option (and would have to be hard coded into a table in any case, as far as I'm aware, either in a query or in a table design. This is something I'm loathe to do). Ideally, the secretary would be able to press a button on a form and have all the mark entry tables for all the papers created automagically.

The examiners for the different papers change every year, and not every academic marks exams every year, so this data will not remain static. Hard coding a table with examiner names would make more work for the secretaries. (I want to avoid this as all mark entering for all students is done in a single day. This means over 600 students at 3 marks per student [mark 1, mark 2, and final agreed mark] with time to contact examiners with questions... and only 2 secretaries, each of whom deals with a different section of students).

Because of the nature of the marking, it would also make quite a lot of work for the secretaries if we had to cross reference a generic Examiner_1 field with a different examiner for each paper, so the field name really must be the examiner's actual name.

Can anyone help me? I'm happy to do it with either VB or SQL; I'm not a programmer, but I can usually work out what code does even if I can't write it myself. I should be able to adapt anything presented as long as it's complete and doesn't assume that I know the basics. :) I've also got two reference books to hand: _Microsoft Access 2003 Forms, Reports and Queries_ by Paul McFedries and _How to Do Everything with Microsoft Office Access 2003_ by Virginia Anderson.

Thanks very much for your time. :)

-Jen

View 10 Replies View Related







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