If typeTfMod Then
InstSql.NewType (1, TypeTextField.Text )
idtype = InstSql.GetLastIdType
End If
In the InstSql module
Sub GetLastIdType
requete = "select max(idtype) from type"
LastID
End Sub
Sub GetLastIdFormat
requete = "select max(idformat) from format"
LastID
End Sub
Sub GetLastIdNom
requete = "select max(idnominst) from nominst"
LastID
End Sub
Sub GetLastIdExplic
requete = "select max(idexplic) from explic"
LastID
End Sub
Sub LastID() As Int
Try
Dim Last_ID As Int = Main.SQL.ExecQuerySingleResult (requete)
Catch
Log (LastException)
End Try
Return Last_ID
End Sub
You need to pass requete to the lastID sub, and the lastID sub should have a variable in the signature:
B4X:
private idtype as INT
If typeTfMod Then
InstSql.NewType (1, TypeTextField.Text )
idtype = InstSql.GetLastIdType
End If
In the InstSql module
Sub GetLastIdType
requete = "select max(idtype) from type"
ID = LastID(requete)
End Sub
Sub LastID(requete as String) As Int
Try
Dim Last_ID As Int = Main.SQL.ExecQuerySingleResult (requete)
Catch
Log (LastException)
End Try
Return Last_ID
End Sub