Ti ringrazio Alex per la tua risposta , grazie alla quale sono andato a rivedere il tutto , Ed in effetti di errore ve ne erano molti. Non sono sicuramente bravo a sviluppare sw , sono ormai passati anni da quando utilizzavo Clipper, ma ho sempre cercato di capire le cose anche scopiazzando un pò. Qui sotto trovi l'elaborato corretto e ti posso garantire che non utilizzo "in modo maldestro con CHATGPT". Utilizzo VBA solo per passione, per cui posso sicuramente fare arrosti ma, non mi si può dire che faccio le cose senza cercare di capire, purtroppo non sempre mi riesce. Ovviamente ogni tua osservazione e bene accetta.
Sub TestDatiMascheraDBesterno()
On Error GoTo Err_Handler
Dim obj As AccessObject
Dim accapp As Access.Application
Dim CP As CodeProject
Set accapp = New Access.Application
Dim frm As Access.Form
Dim rs As Recordset
Dim ctl As Control
Dim fld As Field
''' Apro db esterno
accapp.OpenCurrentDatabase ("C:\Archivio\Access\database1.accdb")
Set CP = accapp.CurrentProject
''' Itero tutti i nome delle Form
For Each obj In CP.AllForms
Debug.Print obj.Name
''' Apro la Form su Db esterno
accapp.DoCmd.OpenForm obj.Name, acDesign, , , , acHidden
''' Apro il set
Set frm = accapp.Forms(obj.Name)
Set rs = accapp.DBEngine(0)(0).OpenRecordset(frm.Properties("recordsource"))
''' Leggo i nomi di campi e tabelle contenute in SQL e gli riporto i tabella db_form
For Each fld In rs.Fields
Debug.Print obj.Name, frm.Name, fld.SourceTable, fld.Name, FieldTypeName(fld)
Next fld
''' Leggo i nomi dei controlli e le loro proprieta
For Each ctl In frm
If ctl.Properties("ControlType") >= 105 And ctl.Properties("ControlType") <= 122 Then
Debug.Print ctl.Name, ctl.Properties("ControlType"), IIf(ctl.Properties("Visible") = "vero", True, False), ctl.Properties("Enabled"), ctl.Properties("Tag"), ctl.Properties("ControlSource")
End If
Next ctl
accapp.DoCmd.Close acForm, obj.Name, acSaveNo
Set rs = Nothing
Next obj
Exit_Handler:
accapp.CloseCurrentDatabase
Set frm = Nothing
Set rs = Nothing
Set CP = Nothing
Exit Sub
Err_Handler:
' Debug.Print DBEngine.Errors.Count
If Err.Number = 2455 Or Err.Number = 2467 Then
Debug.Print "scrivi errore" & Err.Number & ": " & Left(Err.Description, InStr(1, Err.Description, ".") - 1)
Err.Clear
Resume Next
ElseIf Err.Number = 3078 Then
Debug.Print "scrivi errore" & Err.Number & ": " & Left(Err.Description, InStr(1, Err.Description, ".") - 1)
Err.Clear
Resume Next
ElseIf Err.Number = 3061 Then
Debug.Print "scrivi errore" & Err.Number & ": " & Left(Err.Description, InStr(1, Err.Description, ".") - 1)
Err.Clear
Resume Next
ElseIf Err.Number = 91 Or Err.Number = 92 Then
Debug.Print "scrivi errore" & Err.Number '& ": " & Left(Err.Description, InStr(1, Err.Description, ".") - 1)
Err.Clear
Resume Next
Else
Debug.Print " errore Non previsto " & Err.Number & " : " & Err.Description
GoTo Exit_Handler
End If
End Sub