Office中国论坛/Access中国论坛

标题: 组合框的记录自动加入 [打印本页]

作者: 小铁匠    时间: 2004-11-9 17:39
标题: 组合框的记录自动加入
请教如何在[单位名称]中自动加入?[em01][attach]7537[/attach]


作者: zhanguoru    时间: 2004-11-9 17:50
两种思路法:1.用addnew方法(值清单),例:Me.CboQuery2.AddItem("aa")2.用查询(表/查询),例:dim tkSQL as stringtkSQL="SELECT * FORM 资料表"with combo1.requery.rowsource=tksqlend with 以上,请指教谢谢!!
作者: sxfwang    时间: 2004-11-9 18:03
改一下模块中的程序就可以了,注意你使用的是DAO模式Option Compare Database



Function AddToList(strTable As String, strField As String, _

strData As String) As Integer



    ' Add item to table

    ' Returns acDataErrAdded if successful,

    ' acDataErrDisplay on any error

   

    Dim db As Database

    Dim strSQL As String

   

    Set db = CurrentDb

   

    strSQL = "Insert into " & strTable & " (" & strField & ") Values " _

      & "('" & strData & "')"

    Set db = CurrentDb

    db.Execute strSQLExitHere:

    AddToList = acDataErrAdded

    Exit FunctionHandleErr:

    AddToList = acDataErrDisplay

    Select Case Err

        Case Else

            MsgBox Err & ": " & Err.Description, , _

              "Form_HouseholdInventory.AddToList()"

    End Select

    Resume ExitHere

End Function






欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3