Ms access 这实际上是如何更新表的?

Ms access 这实际上是如何更新表的?,ms-access,ms-access-2007,Ms Access,Ms Access 2007,警告:我对访问编码非常陌生。 我习惯了.NET和PHP 我刚刚把一个Access 95程序转换成Access 2007,现在我正在尝试进行一些更新 我有一个表单可以更新数据库中的表,但我找不到附加的查询,也找不到它实际执行SQL语句的任何地方。请帮忙。谢谢你 这是一张表格上的所有代码 Option Compare Database `enter code here`Option Explicit Private Sub Check158_Click() ' Try and ch

警告:我对访问编码非常陌生。 我习惯了.NET和PHP

我刚刚把一个Access 95程序转换成Access 2007,现在我正在尝试进行一些更新

我有一个表单可以更新数据库中的表,但我找不到附加的查询,也找不到它实际执行SQL语句的任何地方。请帮忙。谢谢你

这是一张表格上的所有代码

    Option Compare Database
`enter code here`Option Explicit
Private Sub Check158_Click()

    ' Try and change sql code
    Me.Combo35.RowSource = "SelectAllOrders"
End Sub

Private Sub Combo35_AfterUpdate()
                                                                                                                                                                                                                            Me.RecordsetClone.FindFirst "[OrderID] = " & Me![Combo35]
    Me.Bookmark = Me.RecordsetClone.Bookmark
    ' Find the record that matches the control.
End Sub

Private Sub Command122_Click()
On Error GoTo Err_Command122_Click


    DoCmd.Close

Exit_Command122_Click:
    Exit Sub

Err_Command122_Click:
    MsgBox Err.Description
    Resume Exit_Command122_Click

End Sub

Private Sub Customer_AfterUpdate()
Forms![Orders]![CustomerID] = [Forms]![Orders]![Customer].Column(0)

Forms![Orders]![Phone] = [Forms]![Orders]![Customer].Column(2)
End Sub

Private Sub Frame40_AfterUpdate()
'Forms![Orders]![Orders Subform].Form![Quantity]
If Forms![Orders]![Frame40] = 1 Then
   ' Me![Orders By Customer Subform].[Requery
   Forms![Orders]![Child81].Form![ProductID].RowSource = "StdPrice"
   Else
   Forms![Orders]![Child81].Form![ProductID].RowSource = "PvtPrice"
End If
End Sub
Private Sub Command131_Click()
On Error GoTo Err_Command131_Click

    Me![Invoice Total] = Forms![Orders]![Child81].Form![Order Subtotal]
    DoCmd.GoToRecord , , acNewRec

Exit_Command131_Click:
    Exit Sub

Err_Command131_Click:
    MsgBox Err.Description
    Resume Exit_Command131_Click

End Sub
Private Sub Command132_Click()
On Error GoTo Err_Command132_Click
    'Cancel Click for Orders

    If Me.Dirty Then DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
    Me![Invoice Total] = Forms![Orders]![Child81].Form![Order Subtotal]
    DoCmd.Close


Exit_Command132_Click:
    Exit Sub

Err_Command132_Click:
    MsgBox Err.Description
    Resume Exit_Command132_Click

End Sub
Private Sub Command133_Click()
On Error GoTo Err_Command133_Click
    'Save and Exit Click

    Me![Invoice Total] = Forms![Orders]![Child81].Form![Order Subtotal]
    DoCmd.Close

Exit_Command133_Click:
    Exit Sub

Err_Command133_Click:
    MsgBox Err.Description
    Resume Exit_Command133_Click

End Sub
Private Sub Command134_Click()
On Error GoTo Err_Command134_Click


    DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

Exit_Command134_Click:
    Exit Sub

Err_Command134_Click:
    MsgBox Err.Description
    Resume Exit_Command134_Click

End Sub
Private Sub Command136_Click()
On Error GoTo Err_Command136_Click

    DoCmd.GoToRecord , , acNext

Exit_Command136_Click:
    Exit Sub

Err_Command136_Click:
    MsgBox Err.Description
    Resume Exit_Command136_Click

End Sub
Private Sub Command138_Click()
On Error GoTo Err_Command138_Click

    Me![Invoice Total] = Forms![Orders]![Child81].Form![Order Subtotal]

    DoCmd.GoToRecord , , acNext

Exit_Command138_Click:
    Exit Sub

Err_Command138_Click:
    MsgBox Err.Description
    Resume Exit_Command138_Click

End Sub
Private Sub Command148_Click()
On Error GoTo Err_Command148_Click

    Dim stDocName As String

    stDocName = "Container Card"
    DoCmd.OpenReport stDocName, acPreview, , "[OrderID] = Forms![Orders]![OrderID]"

Exit_Command148_Click:
    Exit Sub

Err_Command148_Click:
    MsgBox Err.Description
    Resume Exit_Command148_Click

End Sub

Private Sub Form_Close()
'    Me![Invoice Total] = Forms![Orders]![Child81].Form![Order Subtotal]

End Sub
和一个子表单

Option Compare Database
Option Explicit


Private Sub Form_AfterDelConfirm(Status As Integer)
    Forms![Orders]![Child81].Requery
End Sub

Private Sub Form_Open(Cancel As Integer)
'If Forms![Orders]![Frame40] = 1 Then
'   Me![ProductID].RowSource = "StdPrice"
'   Else
'   Me![ProductID].RowSource = "PvtPrice"'
'End If


End Sub


Private Sub ProductID_NotInList(NewData As String, Response As Integer)
    MsgBox "Double-click this field to add an entry to the list."
    Response = acDataErrContinue
End Sub
Private Sub ProductID_AfterUpdate()
 Dim pos As Variant
    Me![UnitPrice] = Me![ProductID].Column(2)
    Me![ProductName] = Me![ProductID].Column(1)
    Me![GLAcct] = Me![ProductID].Column(3)
    Me.Dirty = False
End Sub
Private Sub ProductID_DblClick(Cancel As Integer)
On Error GoTo Err_ProductID_DblClick
    Dim lngProductID As Long

    If IsNull(Me![ProductID]) Then
        Me![ProductID].Text = ""
    Else
        lngProductID = Me![ProductID]
        Me![ProductID] = Null
    End If
    DoCmd.OpenForm "Products", , , , , acDialog, "GotoNew"
    Me!ProductID.Requery
    If lngProductID <> 0 Then Me![ProductID] = lngProductID

Exit_ProductID_DblClick:
    Exit Sub

Err_ProductID_DblClick:
    MsgBox Err.Description
    Resume Exit_ProductID_DblClick
End Sub

Private Sub Command20_Click()
On Error GoTo Err_Command20_Click


    DoCmd.GoToRecord , , acNewRec

Exit_Command20_Click:
    Exit Sub

Err_Command20_Click:
    MsgBox Err.Description
    Resume Exit_Command20_Click

End Sub
Private Sub Command22_Click()
On Error GoTo Err_Command22_Click


    DoCmd.GoToRecord , , acNext

Exit_Command22_Click:
    Exit Sub

Err_Command22_Click:
    MsgBox Err.Description
    Resume Exit_Command22_Click

End Sub
Private Sub Command23_Click()
On Error GoTo Err_Command23_Click


    DoCmd.GoToRecord , , acFirst

Exit_Command23_Click:
    Exit Sub

Err_Command23_Click:
    MsgBox Err.Description
    Resume Exit_Command23_Click

End Sub
Private Sub Command24_Click()
On Error GoTo Err_Command24_Click


    DoCmd.GoToRecord , , acPrevious

Exit_Command24_Click:
    Exit Sub

Err_Command24_Click:
    MsgBox Err.Description
    Resume Exit_Command24_Click

End Sub
Private Sub Command25_Click()
On Error GoTo Err_Command25_Click


    DoCmd.GoToRecord , , acLast

Exit_Command25_Click:
    Exit Sub

Err_Command25_Click:
    MsgBox Err.Description
    Resume Exit_Command25_Click

End Sub
Private Sub Command26_Click()
On Error GoTo Err_Command26_Click


    DoCmd.GoToRecord , , acNext

Exit_Command26_Click:
    Exit Sub

Err_Command26_Click:
    MsgBox Err.Description
    Resume Exit_Command26_Click

End Sub

Private Sub Quantity_AfterUpdate()
Dim pos As Variant
'Me.Dirty = False

End Sub

Private Sub UnitPrice_AfterUpdate()
Dim pos As Variant
'Me.Dirty = False

End Sub
Private Sub Command33_Click()
On Error GoTo Err_Command33_Click


    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command33_Click:
    Exit Sub

Err_Command33_Click:
    MsgBox Err.Description
    Resume Exit_Command33_Click

End Sub
选项比较数据库
选项显式
私有子表单\u AfterDelConfirm(状态为整数)
形式![命令]![Child81]。重新查询
端接头
私有子表单_打开(取消为整数)
“如果形式![命令]![Frame40]=1那么
“我![ProductID].RowSource=“StdPrice”
”“否则呢
“我![ProductID].RowSource=“PvtPrice”'
"完"
端接头
私有子产品ID\u NotInList(新数据为字符串,响应为整数)
MsgBox“双击此字段可将条目添加到列表中。”
Response=acDataErrContinue
端接头
私有子产品ID_AfterUpdate()
作为变体的Dim pos
我[单价]=我![ProductID]。第(2)列
我[ProductName]=我![ProductID]。第(1)列
我我![ProductID]。第(3)列
我,肮脏=虚假
端接头
私有子产品ID_DblClick(取消为整数)
On Error GoTo Err\u ProductID\u DblClick
Dim lngProductID的长度为
如果为null(Me![ProductID]),则
我[ProductID]。Text=“”
其他的
lngProductID=我![产品ID]
我[ProductID]=Null
如果结束
DoCmd.OpenForm“产品”,acDialog,“GotoNew”
我产品ID重新查询
如果lngProductID为0,则为我![ProductID]=lngProductID
退出\u ProductID\u DblClick:
出口接头
Err_ProductID_DblClick:
MsgBox错误说明
继续退出\u ProductID\u DblClick
端接头
专用子命令20_Click()
错误转到错误命令20\u单击
文件编号:GoToRecord,acNewRec
退出命令20\u单击:
出口接头
错误命令20\u单击:
MsgBox错误说明
继续退出命令20\u单击
端接头
专用子命令22_Click()
错误转到错误命令22\u单击
DoCmd.GoToRecord,acNext
退出命令22\u单击:
出口接头
错误命令22\u单击:
MsgBox错误说明
继续退出命令22_单击
端接头
专用子命令23_Click()
错误转到错误命令23\u单击
DoCmd.GoToRecord,acFirst
退出命令23\u单击:
出口接头
错误命令23\u单击:
MsgBox错误说明
继续退出命令23_单击
端接头
专用子命令24_Click()
错误转到错误命令24\u单击
DoCmd.GoToRecord,ACP
退出命令24\u单击:
出口接头
错误命令24\u单击:
MsgBox错误说明
继续退出命令24_单击
端接头
专用子命令25_Click()
错误转到错误命令25\u单击
DoCmd.GoToRecord,acLast
退出命令25\u单击:
出口接头
错误命令25\u单击:
MsgBox错误说明
继续退出命令25_单击
端接头
专用子命令26_Click()
错误转到错误命令26\u单击
DoCmd.GoToRecord,acNext
退出命令26\u单击:
出口接头
错误命令26\u单击:
MsgBox错误说明
继续退出命令26_单击
端接头
私有子数量\u更新后()
作为变体的Dim pos
“我,肮脏=虚假
端接头
私有子单价\u更新后()
作为变体的Dim pos
“我,肮脏=虚假
端接头
专用子命令33_Click()
错误转到错误命令33\u单击
DoCmd.DoMenuItem acFormBar、acEditMenu、8、acMenuVer70
DoCmd.DoMenuItem acFormBar,acEditMenu,6,acMenuVer70
退出命令33\u单击:
出口接头
错误命令33\u单击:
MsgBox错误说明
继续退出命令33\u单击
端接头

第一个示例中的表单可能是一个数据绑定表单-它应该有一个数据源集,它将是用于填充表单上字段的查询或表。如果编辑表单上的值并关闭表单,它将自动提交对该查询下的表所做的更改


第二个示例有一些导航按钮……从当前记录导航出去也会自动导致提交。再次查看表单的datasource属性,了解它正在更新的内容。

AWESOME!哈哈,非常感谢,现在一切都有了意义。我是否可以通过这种方式使某些字段成为必填字段,以便在未填写这些字段的情况下无法提交?如果要使用Access,您需要学习如何以交互方式使用它。这意味着学习如何在Access UI中创建表,然后学习如何创建绑定表单来编辑这些表。这些都不需要任何代码——都是在幕后为您完成的。您发布的大部分代码都没有任何作用,我敢打赌,这些子例程中的许多甚至不再附加到以其命名的控件上。@David我愿意这样做。你推荐什么好的在线资源吗?我必须用谷歌搜索任何在线资源(我不需要它们,因为我在1996年学会了如何交互使用Access!)——我想你可能也能像我一样用谷歌搜索。您可能会签出,因为它可能有指向Gettin启动类型站点的指针。而且,和可能有良好的入门链接,但也不是作为教程设计的网站。Access帮助肯定有某种链接到MS的在线教程(我不能检查我在防火墙中阻止访问)。考虑一本书:你发布的代码是一个神圣的混乱。我知道你继承了它,所以这不是你的错,但不管是谁写的,他都是一个不符合标准的访问程序员。“混乱”刚开始描述它,我认为你想要的词是“邪恶”!:)