بالنسبة للسؤال الاول
if declared in same form replace public with private
=================================================
Option Compare Database
'Declarations
Public Type OPENFILENAME
lStructSize As Long '=========
hwndOwner As Long
hInstance As Long
lpstrFilter As String '=========
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String '=========
nMaxFile As Long '=========
lpstrFileTitle As String '=========
nMaxFileTitle As Long '=========
lpstrInitialDir As String '=========
lpstrTitle As String
flags As Long '=========
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
=================================
=======================================================
'حيث C_NAME4 هو مربع نص يسجل به المسار
Private Sub C_NAME4_DblClick(Cancel As Integer)
Dim ofn As OPENFILENAME
ofn.lStructSize = Len(ofn)
'ofn.hwndOwner = Me.Hwnd
'ofn.hInstance = App.hInstance
ofn.lpstrFilter = "Mdb Files (*.mdb)" + Chr$(0) + "*.mdb" + Chr$(0) + "Mde Files (*.mde)" + Chr$(0) + "*.mde" + Chr$(0)
ofn.lpstrFile = Space$(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space$(254)
ofn.nMaxFileTitle = 255
ofn.lpstrInitialDir = CurDir
ofn.lpstrTitle = " MT Software "
ofn.flags = 0
Dim A
A = GetOpenFileName(ofn)
If (a) Then
Me![C_NAME4] = Trim$(ofn.lpstrFile)
'MsgBox "File to Open: " + Trim$(ofn.lpstrFile)
Else
MsgBox "Cancel was pressed"
End If
Exit Sub
CmdBrowseErrHandler:
If Err.Number = 32755 Then
MsgBox " You did not change the file name ", 64, "Alert Message "
ElseIf Err.Number = 20477 Then
MsgBox " Invalid file name ", 16, "Alert Message "
Else
MsgBox Str(Err.Number) + Err.Description
End If
'Exit Sub
End Sub