我在vba中有一个代码,其中访问2010写在一个按钮的点击事件里面,当我点击这个它给我错误说“用户定义的类型未定义”这是我的代码:
Private Sub cmdBrowse_Click()
Dim FileOpenDialog As FileDialog
Set FileOpenDialog = Application.FileDialog(msoFileDialogFilePicker)
Dim SelectedFile As Variant
Dim db As DAO.Database
Set db = CurrentDb
With FileOpenDialog
.AllowMultiSelect = False
.Title = "Select A File To Use As A Logo"
.Filters.Clear
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg;*.bmp;*.png"
.ButtonName = "Use This File"
If .Show = True Then
For Each SelectedFile In .SelectedItems
Dim LogoFile As String
LogoFile = SelectedFile
Dim barewabarayate As Recordset
Set barewabarayate = db.OpenRecordset("barewabarayate")
With barewabarayate
.Edit
barewabarayate.Fields("image_path") = LogoFile
barewabarayate.Update
End With
Next
End If
End With
End Sub
答案 0 :(得分:2)
同意Remou;我得到了相同的错误,直到我在Access 2010中有以下参考:
Microsoft Office 14.0 Object Library
从VB代码编辑器中,选择Tools菜单,然后选择References ...