Create Table Error (SQL inside Macro)

PedroDC

Board Regular
Joined
Feb 15, 2005
Messages
116
Greetings.

I have a macro in access wich is supposed (among other things) to create a new table.

However, I'm having trouble with the Data Type definition, because I get the message:

"Runtime Error 3292: Syntax error in field definition."


The code I'm using is:

Code:
SQL = "CREATE TABLE Relatorio(EXTRATO), FlightDate Date(dd/mm/yyyy)"
DoCmd.RunSQL SQL

Please help!
Many thanks in advance
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I'm not 100% sure what you want to do but this code works for me.
Code:
SQL = "CREATE TABLE Relatorio (FlightDate Date)"
DoCmd.RunSQL SQL

It creates a table called Relatorio with a Date field named FlightDate.

Is that what you want?
 
Upvote 0
I was able to get this SQL string to create table Relatorio:

CREATE TABLE Relatorio(EXTRATO text(5), FlightDate Date;"

This created the table, a field named EXTRATO that is text, and 5 characters, then FlightDate as a date.

I could not find the documentation on how to define the format for a field, such as dd/mm/yyyy as the format the the FlightDate.

But the statement did create the table.
HTH,
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top