Open remote form

giovedì 19 luglio 2018 - 09.15

fabrizionistri Profilo | Newbie

Buonasera,
chiedo il Vostro aiuto perché aprendo una maschera su altro DB tramite un comando, nel DB di destinazione si creano due nuovi record anziché uno come correttamente dovrebbe funzionare, dove sbaglio ? il codice è il seguente:

Function OpenRemoteForm(strMDB As String, strForm As String) As Boolean
Dim Msg, Style, Title, Response
Dim objAccess As New Access.Application
Dim lngRet As Long
Dim str As String
Dim numt As Long
Dim numm As Long
Dim it As Long
Dim im As Long
Dim vart As Long
Dim varm As Long
Dim rstT As New ADODB.Recordset
Dim rstM As New ADODB.Recordset

str = Right(DLookup("EsercizioF", "TblEsercizio"), 4)
strMDB = "C:\Users\fabrizio.nistri\Desktop\GESTIONE_AGRICOLTURA\GESTIONE_AGRICOLTURA_" & str & "\moM.accdb"

'trattori
tr:
strForm = "TRATTORI"
If Len(Dir(strMDB)) > 0 Then
Set objAccess = New Access.Application
With objAccess
lngRet = apiSetForegroundWindow(.hWndAccessApp)
lngRet = apiShowWindow(.hWndAccessApp, SW_NORMAL)
lngRet = apiShowWindow(.hWndAccessApp, SW_NORMAL)
.OpenCurrentDatabase strMDB
vart = DLookup("[IdTrattore]", "Trattori", "[IdTrattore] =" & Form_FRM_SUBORE.Mezzo.Column(0))
rstT.Open "Select * From Trattori ORDER BY IdTrattore", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
numt = rstT.RecordCount
For it = 1 To numt
If vart = rstT!IdTrattore Then
Exit For
End If
rstT.MoveNext
Next it
.DoCmd.OpenForm strForm, acNormal, , , acFormEdit, acWindowNormal
.DoCmd.GoToRecord acDataForm, strForm, acGoTo, it
.Forms.Item(SUB_TRATTORI).TR_ENTRY_EST = "S"
.Forms.Item(strForm).appoData = Form_FRM_RILEVAZIONI.Data
.Forms.Item(strForm).appoDIPE = Form_FRM_RILEVAZIONI.Dipendente
.DoCmd.GoToControl "SDIT"
End With
rstT.Close
GoTo OpenRemoteForm_Exit:
End If

grazie mille per la Vostra collaborazione
cordiali saluti
Fabrizio Nistri
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5