如何使用程序修改access数据库中数据表的字段名
答案:2 悬赏:20 手机版
解决时间 2021-02-14 13:25
- 提问者网友:杀生予夺
- 2021-02-13 22:35
如何使用程序修改access数据库中数据表的字段名
最佳答案
- 五星知识达人网友:蓝房子
- 2021-02-13 23:53
Sub EditFieldName(ByVal TableName As String, ByVal FieldName As String, ByVal NewFieldName As String)
On Error GoTo ErrP
Dim TDS As TableDefs
Dim TD As TableDef
Dim F As dao.Field
Set TDS = CurrentDb.TableDefs
Set TD = TDS(TableName)
Set F = TD.Fields(FieldName)
F.Properties("Name") = NewFieldName
ExitSub:
Set F = Nothing
Set TD = Nothing
Set TDS = Nothing
Exit Sub
ErrP:
MsgBox Err.Number & " " & Err.Description
GoTo ExitSub
End Sub
三个参数,第一个表名,第二个是原字段名,第三个是新字段名
On Error GoTo ErrP
Dim TDS As TableDefs
Dim TD As TableDef
Dim F As dao.Field
Set TDS = CurrentDb.TableDefs
Set TD = TDS(TableName)
Set F = TD.Fields(FieldName)
F.Properties("Name") = NewFieldName
ExitSub:
Set F = Nothing
Set TD = Nothing
Set TDS = Nothing
Exit Sub
ErrP:
MsgBox Err.Number & " " & Err.Description
GoTo ExitSub
End Sub
三个参数,第一个表名,第二个是原字段名,第三个是新字段名
全部回答
- 1楼网友:旧脸谱
- 2021-02-14 01:09
做一个查询,查询的sql语句如下所示,然后插入子数据表的时候,选择查询就行了
select a.学生姓名, a.学期, a.成绩, c.平均分
from table2 as a inner join (select b.学期, avg(b.成绩) as 平均分 from table2 as b group by b.学期) as c on a.学期 = c.学期;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯