English 中文(简体)
2003年MS Access to - VBA for changing a table after a “SlectT * INTO tblTemp from tblMain” statement
原标题:MS Access 2003 - VBA for altering a table after a "SELECT * INTO tblTemp FROM tblMain" statement

我利用以下职能,在交叉提问中作临时表格。

Function SQL_Tester()
Dim sql As String

If DCount("*", "MSysObjects", "[Name]= tblTemp ") Then
   DoCmd.DeleteObject acTable, "tblTemp"
End If

sql = "SELECT * INTO tblTemp from TblMain;"

 Debug.Print (sql)

  Set db = CurrentDb
  db.Execute (sql)

End Function

我这样做是为了让我能够用更多的真枪来临时坐下来,利用一些前哨功能(原状和这种功能),然后把这些价值退回到原来的表格(图林)。 即将到来的简单地点是,在特选国际热带木材组织发言之后,我需要在该临时表格中增加一个新的品牌,我不知道如何这样做:

sql = "Create Table..."

就像知道如何做到这一点的唯一方式,当然,这并不完全符合上述做法,因为我无法提出一个在事实之后已经建立的表格,因此我无法在之前创建这一表格,因为选任考试委员会的声明方法将回复到“已经存在的表格”。

任何帮助? 感谢gu!

最佳回答

我可以想到你能够做到这一点的以下途径。

1. Creat, 然后插入

您可在所有需要栏目上填写<代码>。 当然,你的栏目比TblMain的栏目要多,因此,你插入一栏定义。

<编码> INSERT INTO tblTemp (Col1, Col2, Col3) SlectT Col1, Col2, Col3 from TblMain

2. 插入Into, 然后添加栏。

你们可以做些什么,然后用多种方式增加一栏。

  1. In VBA, use the TableDef object to point to tblTemp and then add a column to it
  2. Execute DoCmd.RunSQL "ALTER TABLE tblTemp Add Column MyNewColumn (OTTOMH)
问题回答

总是有不止一种方式去看一线。 你们可以使用农业部? 这样做的好处是能够确定新创建的外地的各种特性,这些特性在通过进入区内的用户界面创造新的领域时就能够做到。 只是一个想法:-

该子的创建和测试在2007年进入时应当与任何版本一致。

Public Sub AddField()

Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Dim strTable As String

Set dbs = CurrentDb

strTable = "tblTemp"

 create the TableDef object that
 wish to change
Set tdf = dbs.TableDefs(strTable)
 create new field
Set fld = tdf.CreateField("Name", dbText)
 set property of new created field
fld.AllowZeroLength = True
 append the new field to the tabledef
tdf.Fields.Append fld

End Sub




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...