“CREATE TABLE"生成运行时错误“3290" [英] 'CREATE TABLE' generates Run-time error '3290'

查看:80
本文介绍了“CREATE TABLE"生成运行时错误“3290"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在第一个 CREATE TABLE 语句中有语法问题.

I have a syntax issue in the first CREATE TABLE statement.

我收到以下 VBA 错误:

I'm receiving the following VBA error:

运行时错误3290"

目标是根据特定列中的值将不同的数据移动到新表中.之后原始表被清除,每个不同的值将再次插入.之后临时表将被删除.

The goal is to move the distinct data to a new table dependent on values in specific columns. Afterwards the original table is cleared, and every distinct value will be inserted again. The temporary table will be deleted afterwards.

' ** Issue here ** '
db.Execute ("CREATE TABLE tTemp AS (SELECT DISTINCT History_Date, Sedol, Selskabsnavn, MarketCap, JQScore, JQ_Rank, Value_Rank, Quality_Rank, Momentum_Rank FROM JQHistory)")

db.Execute ("DELETE * FROM JQHistory")
db.Execute ("SELECT * FROM tTemp INTO JQHistory")
db.Execute ("DROP TABLE tTemp")

此代码正在 MS Excel 中运行.

This code is being run from within MS Excel.

推荐答案

您已经有了在第三个语句中实现此功能的语法,尽管它并不完全正确.

You already have the syntax to make this work in the third statement, although it's not quite correct.

第一行应该是db.Execute ("SELECT DISTINCT <字段列表> INTO tTemp FROM JQH​​istory")

第三条语句应该是:db.Execute ("INSERT INTO JQHistory SELECT <字段列表> FROM tTemp")

这篇关于“CREATE TABLE"生成运行时错误“3290"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆