07-10-21, 09:12 AM
هذا الكود شغال في الاكسس
ممكن كود نفس عملة بس يعمل في فجول ليسك
ممكن كود نفس عملة بس يعمل في فجول ليسك
كود :
Private Sub cmdAdd_Click()
Dim strFilter As String
Dim lngflags As Long
Dim varFileName As Variant
strFilter = "All Files (*mdb*)" & vbNullChar & "*mdb*" _
& vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
lngflags = tscFNPathMustExist Or tscFNFileMustExist _
Or tscFNHideReadOnly
varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngflags, _
strDialogTitle:="الرجاء اختيار ملف ...")
If IsNull(varFileName) Then
Else
Me![DataFile] = varFileName
End If
cmdAdd_End:
On Error GoTo 0
Exit Sub
cmdAdd_Err:
Beep
MsgBox Err.Description, , "Error: " & Err.Number _
& " in file"
Resume cmdAdd_End
End Sub
Private Sub CmdOPEN_Click()
Dim acc As Access.Application
Dim db As DAO.Database
Dim strDbName, strMeName As String
strDbName = Me.DataFile
Set acc = New Access.Application
With acc
.Visible = True
Set db = .DBEngine.OpenDatabase(strDbName, False, False, ";PWD=" & Me.PswData)
.OpenCurrentDatabase strDbName
.UserControl = True
End With
db.Close
Set db = Nothing
Set acc = Nothing
Application.Quit
End Sub