Riassumendo la struttura è la seguente:
dalla form principale, premendo il tasto in questione, chiamo la funzione creaReport in un modulo
codice:
Private Sub cmdRep_Click()
Call creaReport
End Sub
la funzione che si trova nel modulo è quella che effettua diversi cicli
codice:
Public Function creaReport()
Dim strSqlGen As String
Dim rsSqlGen As Recordset
strSqlGen = "query effettuata"
Call GetRecordset(mi restituisce un recordset)
Do While Not rsSqlGen.EOF
Dim condBio As String
condNOME = ""
countNOME = 1
Dim nome As String
Dim trePar As Integer
RtnStr = Space(1024)
While condNOME <> "0"
sRetVal = GetPrivateProfileString("NOME" & countNOME, "CONDIZIONE", "0", RtnStr, 1024, App.path & "\" & "File.ini")
condNOME = Left$(RtnStr, sRetVal) ' extract the returned string from the buffer
sRetVal = GetPrivateProfileString("NOME" & countNOME, "VAL1", "0", RtnStr, 1024, App.path & "\" & "File.ini")
nome = Left$(RtnStr, sRetVal) ' extract the returned string from the buffer
sRetVal = GetPrivateProfileString("NOME" & countNOME, "VAL2", "0", RtnStr, 1024, App.path & "\" & "File.ini")
trePar = Left$(RtnStr, sRetVal) ' extract the returned string from the buffer
Call creaTabReport(condNOME, rsSqlGen!id_ind_r, rsSqlGen!id_acq, nome, trePar)
countNOME = countNOME + 1
sRetVal = GetPrivateProfileString("NOME" & countNOME, "CONDIZIONE", "0", RtnStr, 1024, App.path & "\" & "File.ini")
condNOME = Left$(RtnStr, sRetVal) ' extract the returned string from the buffer
Wend
rsSqlGen.MoveNext
'Wend
Loop
ConnIni.Close
End Function
Public Function creaTabReport(parametri passati)
Dim StrSQLInsert As String
Dim strSQLUpdate As String
Dim strSQLSesAcq As String
Dim rsSQLSesAcq As Recordset
strSQLSesAcq = "effettuo query"
Call GetRecordset(recordset restituito)
Do While Not rsSQLSesAcq.EOF
Dim StrSQLCompl As String
Dim rsSqlCompl As Recordset
Dim boolAcqCompleta As Boolean
boolAcqCompleta = True
StrSQLCompl = "query con all'interno i parametri passati"
Call GetRecordset(funzione che mi restituisce un recordset)
If rsSqlCompl.RecordCount = 0 Then '
StrSQLInsert = "comando update in sql"
comm.CommandText = StrSQLInsert
comm.Execute
Set rsSqlCompl = Nothing
boolAcqCompleta = False
If boolUpdateNO Then
strSQLUpdate = "comando update in sql"
comm.CommandText = strSQLUpdate
comm.Execute
boolUpdateNO = False
End If
End If
Next
Else
StrSQLInsert = "comando update in sql"
comm.CommandText = StrSQLInsert
comm.Execute
boolAcqCompleta = False
If boolUpdateNO Then
'Mi aggiorna anche il campo COMPL_BIO di INDIVIDUO
strSQLUpdate = "comando update in sql"
comm.CommandText = strSQLUpdate
comm.Execute
boolUpdateNO = False
End If
End If
If boolAcqCompleta Then
StrSQLInsert = "comando update in sql"
comm.CommandText = StrSQLInsert
comm.Execute
If boolUpdateNO Then
strSQLUpdate = "comando update in sql"
comm.CommandText = strSQLUpdate
comm.Execute
' boolUpdate = False
End If
End If
rsSQLSesAcq.MoveNext
Loop
Set rsSQLSesAcq = Nothing
End Function
questa è la struttura generale, ovvero, effettuo una query principale, per ogni record applico delle condizioni scritte in un file .ini, e in base a quanto trovato nel file .ini, proseguo con opportune verifiche attraverso altre query e cicli.