Oppure

Loading
26/06/22 14:19
islington
salve a tutti ho un problema con un programma di contabilita secolare che ho rispolverato ed alla quale volevo fare qualche modifica, ma sono molto arrugginito ed il progamma era gia fatto un po così
praticamente richiamando una routine che mi esgue calcoli in automatico, quando vado a prendere gli articoli dal database mi prende solo il prezzo senza prelevare codice e descrizione, do ho errato?
cerco di postare le due parti di codice interessato, è un po lungo e non so
questo è il codice del preventibo

Option Compare Text
Dim salva As Boolean
Dim flag As Boolean
Dim T_IVA As Double, t_netto As Double
Dim attuale As Integer
#If Win32 Then

Private Declare Function SetBkMode Lib "gdi32" _
(ByVal hDC As Long, ByVal nBkMode As Long) As Long

Private iBKMode As Long

#Else

Private Declare Function SetBkMode Lib "GDI" (ByVal hDC As Integer _
, ByVal nBkMode As Integer) As Integer

Private iBKMode As Integer

#End If

Private Const TRANSPARENT = 1
Private Const OPAQUE = 2
Public Sub riordino()

' DB_PREV.Refresh
' DB_PREV.Recordset.MoveLast

DBGrid1.Columns(0).Visible = False
DBGrid1.Columns(1).Visible = False
DBGrid1.Columns(2).Visible = False
DBGrid1.Columns(3).Width = 720
DBGrid1.Columns(3).Alignment = 2
DBGrid1.Columns(4).Width = 1120
DBGrid1.Columns(4).Alignment = 2
DBGrid1.Columns(5).Width = 5900
DBGrid1.Columns(6).Width = 600
DBGrid1.Columns(6).Alignment = 2
DBGrid1.Columns(7).Width = 1100
DBGrid1.Columns(7).Alignment = 2
DBGrid1.Columns(8).Width = 1000
DBGrid1.Columns(9).Width = 1000
DBGrid1.Columns(10).Width = 1000
DBGrid1.Columns(11).Width = 1000
DBGrid1.Columns(12).Width = 1000
DBGrid1.Columns(13).Width = 1000
DBGrid1.Columns(14).Width = 1000
DBGrid1.Columns(15).Width = 700
DBGrid1.Columns(16).Width = 1000
' DBGrid1.SetFocus


End Sub
Function dividi(descr As String, l As Integer) As String
Dim cont As Integer
Dim lung As Integer
Dim spazio As String
' Lunghezza stringa restituita
lung = l
If Len(descr) <= lung Then
dividi = descr
Else
cont = lung
spazio = Mid(descr, lung, 1)
While Not spazio = " "
cont = cont - 1
spazio = Mid(descr, cont, 1)
Wend
dividi = Mid(descr, 1, cont)
End If
End Function

Private Sub CANCELLA()
Des.Text = ""
Um.Text = ""
Prunit.Text = ""
Prscont.Text = ""
Sconto.Text = ""
IVA.Text = ""
L9.Visible = False
L10.Visible = False
Costo.Visible = False
Ricarico.Visible = False
End Sub

Private Sub Stampa(pagina As Integer, stringa As String)
If pagina = 0 Or pagina = attuale Then
Printer.Print stringa
End If
End Sub

Private Sub Bt_addnota_Click()
If Not IsNull(DB_STOPRE.Recordset("NOTE";)) Then
Note.Text = DB_STOPRE.Recordset("NOTE";)
Else
Note.Text = ""
End If
Note.Visible = True
L_note.Visible = True
BT_insnota.Visible = True
Bt_annota.Visible = True
BT_parz.Visible = False
BT_forn.Visible = False
BT_var.Visible = False
Note.SetFocus
Bt_addnota.Visible = False
Call riordino
'Call Calcoli
End Sub


Private Sub BT_AnNota_Click()
Note.Visible = False
L_note.Visible = False
BT_insnota.Visible = False
Bt_annota.Visible = False
BT_parz.Visible = True
BT_var.Visible = True
Bt_addnota.Visible = True
BT_forn.Visible = True
DBGrid1.SetFocus
Call riordino
'Call Calcoli
End Sub

Private Sub BT_annvoce_Click()
BT_var.Visible = True
Bt_addnota.Visible = True
BT_parz.Visible = True
BT_newvoce.Visible = True
BT_elart.Visible = False
L9.Visible = False
L10.Visible = False
Costo.Visible = False
Ricarico.Visible = False
BT_modvoce.Visible = True
BT_cancvoce.Visible = True
BT_insvoce.Visible = False
BT_sta.Visible = True
scelta.Visible = False
BT_annvoce.Visible = False
BT_forn.Visible = True
flag = False
DB_PREV.Recordset.MoveLast
DB_PREV.Recordset.Delete
DB_PREV.Recordset.MoveLast
DBGrid1.SetFocus
Call riordino
'Call Calcoli
End Sub

Private Sub Bt_cancVoce_Click()
Dim Msg As String
Dim tipo_finmsg As Integer
If Not DB_PREV.Recordset.EOF Then
tipo_finmsg = 4
Msg = "Conferma la Cancellazione della voce dal documento ?"
If MsgBox(Msg, tipo_finmsg, "Cancella da Documento";) = 6 Then
DB_PREV.Recordset.Delete
DB_PREV.Recordset.MoveNext
If DB_PREV.Recordset.EOF Then
DB_PREV.Refresh
If Not DB_PREV.Recordset.EOF Then DB_PREV.Recordset.MoveLast
End If
DBGrid1.SetFocus
' Me.Timer1.Enabled = True
Call Calcoli
Call riordino

End If
End If
'Call riordino
'Call Calcoli
End Sub

Private Sub BT_elart_Click()
scelta.ZOrder 0
scelta.Visible = True
End Sub

Private Sub BT_forn_Click()
F_CAMFOR.cliente = DB_STOPRE.Recordset("CLIENTE";)
F_CAMFOR.NORD = NORD.Text
F_CAMFOR.DATA = DATA.Text
F_PREINS.Hide
F_CAMFOR.Show
End Sub

Private Sub BT_insnota_Click()
DB_STOPRE.Recordset.Edit
DB_STOPRE.Recordset("NOTE";) = Note.Text
DB_STOPRE.Recordset.Update
Note.Visible = False
L_note.Visible = False
BT_insnota.Visible = False
Bt_annota.Visible = False
BT_parz.Visible = True
BT_var.Visible = True
BT_forn.Visible = True
Bt_addnota.Visible = True
DBGrid1.SetFocus
End Sub

Private Sub BT_insvoce_Click()
IVA.Text = DB_STOPRE.Recordset("IVA";)
salva = True
DB_PREV.Recordset.Edit
DB_PREV.Recordset("NUMERO";) = NORD.Text
If Qty.Text <> "" And Prscont.Text <> "" Then
DB_PREV.Recordset("IMPORTO";) = Format((Qty.Text * Prscont.Text), F_MENU.FormatoEuro)
End If
If Qty.Text <> "" And UDC.Text <> "" Then
DB_PREV.Recordset("Tot_UDC";) = Format((Qty.Text * UDC.Text), F_MENU.FormatoEuro)
End If
If Qty.Text <> "" And MANOD.Text <> "" Then
DB_PREV.Recordset("TMANOD";) = Format((Qty.Text * MANOD.Text), F_MENU.FormatoEuro)
End If

DB_PREV.Recordset.Update
salva = False
BT_var.Visible = True
Bt_addnota.Visible = True
BT_parz.Visible = True
BT_sta.Visible = True
BT_newvoce.Visible = True
BT_modvoce.Visible = True
BT_cancvoce.Visible = True
BT_elart.Visible = False
scelta.Visible = False
L9.Visible = False
L10.Visible = False
Costo.Visible = False
Ricarico.Visible = False
BT_insvoce.Visible = False
BT_annvoce.Visible = False
BT_forn.Visible = True
DB_PREV.Recordset.MoveLast
DBGrid1.SetFocus
flag = False

Call Calcoli
Call riordino

' DBGrid1.SetFocus
End Sub


Private Sub BT_modvoce_Click()
If Not DB_PREV.Recordset.EOF Then
salva = True
DB_PREV.Recordset.Edit
If Qty.Text <> "" And Prscont.Text <> "" Then
DB_PREV.Recordset("IMPORTO";) = Format((Qty.Text * Prscont.Text), F_MENU.FormatoEuro)
End If
If Qty.Text <> "" And UDC.Text <> "" Then
DB_PREV.Recordset("TOT_UDC";) = Format((Qty.Text * UDC.Text), F_MENU.FormatoEuro)
End If
If Qty.Text <> "" And MANOD.Text <> "" Then
DB_PREV.Recordset("TMANOD";) = Format((Qty.Text * MANOD.Text), F_MENU.FormatoEuro)
End If

DB_PREV.Recordset.Update
salva = False
DBGrid1.SetFocus
End If
Call Calcoli
Call riordino

End Sub


Private Sub BT_newvoce_Click()
' flag = True
DB_PREV.Recordset.AddNew
DB_PREV.Recordset("NUMERO";) = NORD.Text
DB_PREV.Recordset.Update
'con il seguente comando aggiunge voce sempre e solo alla fine del database
DB_PREV.Recordset.MoveLast
Casa.Text = ""
Codice.Text = ""
Des.Text = ""
Um.Text = ""
UDC.Text = ""
TOT_UDC.Text = ""
MANOD.Text = ""
TMANOD.Text = ""
Prunit.Text = ""
Prscont.Text = ""
Sconto.Text = ""
IVA.Text = ""
BT_var.Visible = False
BT_elart.Visible = True
BT_sta.Visible = False
BT_insnota.Visible = False
flag = True
Bt_annota.Visible = False
L_note.Visible = False
Note.Visible = False
Bt_addnota.Visible = False
BT_parz.Visible = False
BT_newvoce.Visible = False
BT_insvoce.Visible = True
BT_annvoce.Visible = True
BT_modvoce.Visible = False
BT_forn.Visible = False
BT_cancvoce.Visible = False
Call riordino
'Call Calcoli
Casa.SetFocus

End Sub

Private Sub Calcoli()
Dim tipo_finmsg As String
Dim Msg As String
Dim IMPO, IVA, TUDC, TMANOD As Double
IMPO = 0
TUDC = 0
IVA = 0
TMANOD = 0
TOT1 = 0
UTIMP = 0
' DB_PREV.Refresh
While Not DB_PREV.Recordset.EOF
If Not IsNull(DB_PREV.Recordset("IMPORTO";)) Then
IMPO = IMPO + DB_PREV.Recordset("IMPORTO";)
End If

If Not IsNull(DB_PREV.Recordset("TOT_UDC";)) Then
TUDC = TUDC + DB_PREV.Recordset("TOT_UDC";)
End If

If Not IsNull(DB_PREV.Recordset("TMANOD";)) Then
TMANOD = TMANOD + DB_PREV.Recordset("TMANOD";)
End If
DB_PREV.Recordset.MoveNext
On Error GoTo errore
Wend

IVA = IMPO * DB_STOPRE.Recordset("IVA";) / 100
TOT1 = TUDC + TMANOD
UTIMP = IMPO - TOT1
tipo_finmsg = 0

tot.Caption = Format(IMPO, F_MENU.FormatoEuro)
IVA1.Caption = Format(IVA, F_MENU.FormatoEuro)
impo1.Caption = Format(IMPO + IVA, F_MENU.FormatoEuro)
TUDC1.Caption = Format(TUDC, F_MENU.FormatoEuro)
TMANOD1.Caption = Format(TMANOD, F_MENU.FormatoEuro)
manodudc.Caption = Format(UTIMP + TMANOD, F_MENU.FormatoEuro)
utilimp.Caption = Format(IMPO - TOT1, F_MENU.FormatoEuro)


' Msg = "IL TOTALE DEI CALCOLI DI PREVENTIVO é " & Chr$(13)
' Msg = Msg & Chr$(13)
' Msg = Msg & "IMPONIBILE : " & Chr$(32) & Format(IMPO, F_MENU.FormatoEuro) & Chr$(13)
' Msg = Msg & "IVA : " & Format(IVA, F_MENU.FormatoEuro) & Chr$(13)
' Msg = Msg & "TOTALE : " & Format(IMPO + IVA, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)


' Msg = Msg & "TOTALE U.D.C. : " & Format(TUDC, F_MENU.FormatoEuro) & Chr$(13)
' Msg = Msg & "TOT. MANOD : " & Format(TMANOD, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)

' Msg = Msg & "MANOD + UDC : " & Format(TUDC + TMANOD, F_MENU.FormatoEuro) & Chr$(13)
' Msg = Msg & "UTILE IMP. : " & Format(IMPO - TOT1, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)

' If MsgBox(Msg, tipo_finmsg, "CALCOLI PREVENTIVO";) = 1 Then
'End If
' DB_PREV.Refresh
' DB_PREV.Recordset.MoveLast


' End If
' salva = False

' Call riordino
' Me.Timer1.Enabled = True
Exit Sub
errore:
MsgBox "è inrtervenuto un erroe !", vbExclamation
On Error Resume Next

End Sub

Private Sub BT_sta_Click()
Dim I As Byte
DB_STAMPANTI.DatabaseName = CurDir & "\SEA.mdb"
DB_STAMPANTI.RecordSource = "db_stampanti"
DB_STAMPANTI.Refresh
I = DB_STAMPANTI.Recordset("IMPOSTATA";)
attualmente.Text = Printers(I).DeviceName
For I = 0 To Printers.Count - 1
Stamp.AddItem Printers(I).DeviceName, I
Next I
st.ZOrder 0
Contratto.Value = 0
st.Visible = True
Call riordino
'Call Calcoli
End Sub

Private Sub BT_var_Click()
Variazione.ZOrder 0
Variazione.Visible = True
var.Text = ""
var.SetFocus
Call riordino
'Call Calcoli
End Sub

Private Sub Casa_LostFocus()
Dim esegui As Boolean
Casa.Text = UCase(Casa.Text)
esegui = True
If Codice.Text <> "" And flag Then
DB_ARTASS.RecordSource = "select * from db_artass where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
DB_ARTASS.Refresh
If Not DB_ARTASS.Recordset.EOF Then
Casa = DB_ARTASS.Recordset("CASA";)
Codice = DB_ARTASS.Recordset("CODICE";)
Des = DB_ARTASS.Recordset("DESCRIZIONE";)
Um = DB_ARTASS.Recordset("UM";)
UDC = DB_ARTASS.Recordset("UDC";)
MANOD = DB_ARTASS.Recordset("Manod";)
Costo = DB_ARTASS.Recordset("COSTO";)
Ricarico = DB_ARTASS.Recordset("RICARICO";)
Prunit = DB_ARTASS.Recordset("LISTINO";)
Prscont = DB_ARTASS.Recordset("LISTINO";)
IVA = DB_ARTASS.Recordset("IVA";)
L9.Visible = True
L10.Visible = True
Costo.Visible = True
Ricarico.Visible = True
Qty.Text = 1
Sconto.Text = 0
esegui = False
Else
Call CANCELLA
End If
If esegui Then
DB_ARTICOLI.RecordSource = "select * from db_articoli where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
DB_ARTICOLI.Refresh
If Not DB_ARTICOLI.Recordset.EOF Then
Casa = DB_ARTICOLI.Recordset("CASA";)
Codice = DB_ARTICOLI.Recordset("CODICE";)
Des = DB_ARTICOLI.Recordset("DESCRIZIONE";)
Um = DB_ARTICOLI.Recordset("UM";)
Costo = DB_ARTICOLI.Recordset("COSTO";)
UDC = DB_ARTICOLI.Recordset("costo";)
Ricarico = DB_ARTICOLI.Recordset("RICARICO";)
Prunit = DB_ARTICOLI.Recordset("LISTINO";)
Prscont = DB_ARTICOLI.Recordset("LISTINO";)
IVA = DB_ARTICOLI.Recordset("IVA";)
L9.Visible = True
L10.Visible = True
Costo.Visible = True
Ricarico.Visible = True
Qty.Text = 1
Sconto.Text = 0
esegui = False
Else
Call CANCELLA
End If
End If
End If
End Sub

Private Sub codice_LostFocus()
Dim esegui As Boolean
Codice.Text = UCase(Codice.Text)
esegui = True
If Casa.Text <> "" And flag Then
DB_ARTASS.RecordSource = "select * from db_artass where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
DB_ARTASS.Refresh
If Not DB_ARTASS.Recordset.EOF Then
Casa = DB_ARTASS.Recordset("CASA";)
Codice = DB_ARTASS.Recordset("CODICE";)
Des = DB_ARTASS.Recordset("DESCRIZIONE";)
Um = DB_ARTASS.Recordset("UM";)
UDC = DB_ARTASS.Recordset("UDC";)
MANOD = DB_ARTASS.Recordset("Manod";)
Costo = DB_ARTASS.Recordset("COSTO";)
Ricarico = DB_ARTASS.Recordset("RICARICO";)
Prunit = DB_ARTASS.Recordset("LISTINO";)
Prscont = DB_ARTASS.Recordset("LISTINO";)
IVA = DB_ARTASS.Recordset("IVA";)
L9.Visible = True
L10.Visible = True
Costo.Visible = True
Ricarico.Visible = True
Qty.Text = 1
Sconto.Text = 0
esegui = False
Else
Call CANCELLA
End If
If esegui Then
DB_ARTICOLI.RecordSource = "select * from db_articoli where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
DB_ARTICOLI.Refresh
If Not DB_ARTICOLI.Recordset.EOF Then
Casa = DB_ARTICOLI.Recordset("CASA";)
Codice = DB_ARTICOLI.Recordset("CODICE";)
Des = DB_ARTICOLI.Recordset("DESCRIZIONE";)
Um = DB_ARTICOLI.Recordset("UM";)
UDC = DB_ARTICOLI.Recordset("COSTO";)
Costo = DB_ARTICOLI.Recordset("COSTO";)
Ricarico = DB_ARTICOLI.Recordset("RICARICO";)
Prunit = DB_ARTICOLI.Recordset("LISTINO";)
Prscont = DB_ARTICOLI.Recordset("LISTINO";)
IVA = DB_ARTICOLI.Recordset("IVA";)

L9.Visible = True
L10.Visible = True
Costo.Visible = True
Ricarico.Visible = True
Qty.Text = 1
Sconto.Text = 0
esegui = False
Else
Call CANCELLA
End If
End If
End If
End Sub

Private Sub Command1_Click()
With F_ARTRMO
.L_DocP.Visible = True
.mnuart.Enabled = False
.mnumenu.Enabled = False
.BT_REGMOD.Visible = False
.BT_CANCELLA.Visible = False
.BT_pins.Visible = True
.BT_pann.Visible = True
End With
scelta.Visible = False
F_ARTRMO.Caption = "Inserimento Articoli Singoli in Preventivo"
F_PREINS.Hide
F_ARTRMO.Show
End Sub

Private Sub Command2_Click()
With F_ASSRMO
.L_DocP.Visible = True
.mnuart.Enabled = False
.mnumenu.Enabled = False
.BT_REGMOD.Visible = False
.BT_CANCELLA.Visible = False
.BT_pins.Visible = True
.BT_pann.Visible = True
End With
scelta.Visible = False
F_ARTRMO.Caption = "Inserimento Articoli Assemblati in Preventivo"
F_PREINS.Hide
F_ASSRMO.Show
End Sub

Private Sub Command3_Click()
scelta.Visible = False
End Sub
Private Sub Command6_Click()
Stamp.Clear
st.Visible = False
End Sub

Private Sub dis_modello()
' verticali
' Printer.Line (42, 8.5)-(95, 8.5)
Printer.Line (42, 16.5)-(95, 16.5) ', RGB(184, 227, 254), BF
Printer.Line (5, 14.5)-(42, 14.5) ', RGB(184, 227, 254), BF
Printer.Line (5, 20.5)-(95, 20.5) ', RGB(184, 227, 254), BF
Printer.Line (5, 22.5)-(95, 22.5) ', RGB(184, 227, 254), BF
Printer.Line (5, 52.5)-(84.5, 52.5) ', RGB(184, 227, 254), BF
Printer.Line (12, 54.5)-(62, 54.5) ', RGB(184, 227, 254), BF
Printer.Line (8, 56)-(62, 56) ', RGB(184, 227, 254), BF
Printer.Line (8, 57.5)-(62, 57.5) ', RGB(184, 227, 254), BF
Printer.Line (84.5, 54.5)-(95, 54.5) ', RGB(184, 227, 254), BF
Printer.Line (84.5, 56.5)-(95, 56.5) ', RGB(184, 227, 254), BF
Printer.Line (5, 58)-(95, 58) ', RGB(184, 227, 254), BF
Printer.Line (5, 60)-(18, 60) ', RGB(184, 227, 254), BF
' orizzontali
Printer.Line (42, 14.5)-(42, 20.5) ', RGB(184, 227, 254), BF
Printer.Line (5, 14.5)-(5, 60) ', RGB(184, 227, 254), BF
Printer.Line (18, 58)-(18, 60) ', RGB(184, 227, 254), BF
' Printer.Line (5, 12)-(5, 62)', RGB(184, 227, 254), BF
Printer.Line (20, 20.5)-(20, 22.5) ', RGB(184, 227, 254), BF
Printer.Line (58, 20.5)-(58, 52.5) ', RGB(184, 227, 254), BF
' Printer.Line (59.5, 12)-(59.5, 62)
Printer.Line (62, 20.5)-(62, 52.5) ', RGB(184, 227, 254), BF
Printer.Line (70, 20.5)-(70, 52.5) ', RGB(184, 227, 254), BF
Printer.Line (65, 52.5)-(65, 58) ', RGB(184, 227, 254), BF
Printer.Line (84.5, 20.5)-(84.5, 58) ', RGB(184, 227, 254), BF
Printer.Line (95, 16.5)-(95, 58) ', RGB(184, 227, 254), BF
End Sub
Private Sub Command7_Click()
Dim fine, OK As Boolean
Dim impor As Double
Dim d1 As String, d2 As String, D3 As String, D4 As String, D5 As String, D6 As String, D7 As String, D8 As String, D11 As String, D21 As String, D31 As String
Dim i1 As String, I2 As String
Dim descrizione As String
Dim indi As String
Dim nota As String
Dim CDA As String
Dim codart As String
Dim Cas As String
Dim Prez As Double
Dim v_netto As Double
Dim Qta As Long
Dim Linea As Integer
Dim tipo_finmsg As Integer
Dim Msg, UMI As String
Dim Lpt As String
Dim V_IVA As Double
Dim v_totale As Double
Dim aliq As Single
Dim lung_sta As Integer
Dim colonna As Integer
Dim pag As Integer
Dim logo As New StdPicture
Dim Appl As Object
Dim Doc As Object

If CInt(copiuz.Text) = 0 Then GoTo Nfatt

If Stamp.ListIndex >= 0 Then
Set Printer = Printers(Stamp.ListIndex)
DB_STAMPANTI.Recordset.Edit
DB_STAMPANTI.Recordset("IMPOSTATA";) = Stamp.ListIndex
DB_STAMPANTI.Recordset.Update
End If

If Contratto.Value = vbChecked Then
Set Appl = CreateObject("Word.Application";)
'background dell'applicazione
Appl.application.Visible = False
On Error GoTo errato
Set Doc = Appl.Documents.Open(App.Path & "\capitolato";)
Doc.FormFields("Data";).Result = DATA.Text 'Adesso
Appl.application.PrintOut
'chiusura dell'applicazione e Doc
Doc.CLOSE (False)
Appl.quit
Set Doc = Nothing
Set Appl = Nothing
End If

' Con 12 caratteri per pollice
' [0..95] colonne
' [0..74] righe
'On Error Resume Next
Printer.ScaleMode = 4
'Printer.ScaleHeight = 330
'Printer.ScaleWidth = 217
Printer.PaperSize = 9
Printer.Copies = copiuz.Text
'Printer.ScaleMode = 6
Printer.FontTransparent = True
'Correctly sets the background mix mode to transparent
iBKMode = SetBkMode(Printer.hDC, TRANSPARENT)

If err.Number > 0 Then
tipo_finmsg = 0
Msg = "Impossibile eseguire la stampa." & Chr$(13)
Msg = Msg & "Verificare che la stampante impostata sia quella corretta"
If MsgBox(Msg, tipo_finmsg, "Stampa Preventivo";) = 1 Then
End If
Else
If tutte.Value = 1 Then
pag = 0
Else
pag = nump.Text
End If
attuale = 1
fine = False
DB_CLIENTI.DatabaseName = CurDir & "\SEA.mdb"
DB_CLIENTI.RecordSource = "select * from db_clienti where codice = " & DB_STOPRE.Recordset("CODCLI";)
DB_CLIENTI.Refresh
aliq = DB_STOPRE.Recordset("IVA";)
DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
DB_PREV.Refresh
While Not fine
F_PREINS.Caption = "STAMPA DEL PREVENTIVO IN CORSO SI PREGA DI ATTENDERE"

' parte dedicata alla stampa del modello su foglio A4

If modulo.Value = vbUnchecked Then
Set logo = LoadPicture(CurDir & "\logoP.bmp";)
Printer.PaintPicture logo, 1, 1, 37, 9


Printer.FontName = "Arial"
Printer.ForeColor = vbBlue 'RGB(184, 227, 254)
Printer.FontSize = 7.5
Printer.CurrentX = 55
Printer.CurrentY = 2
Lpt = "IMPIANTI ELETTRICI CIVILI INDUSTRIALI"
Call Stampa(pag, Lpt)
Printer.CurrentX = 55
Printer.CurrentY = 3
Lpt = "AUDIOVISIVI - SERVICE PER CONCERTI"
Call Stampa(pag, Lpt)
Printer.CurrentX = 55
Printer.CurrentY = 4
Lpt = "COMMERCIO MATERIALE ELETTRICO - TV ANTENNE - TELEFONIA"
Call Stampa(pag, Lpt)
Printer.CurrentX = 55
Printer.CurrentY = 5
Lpt = "DOMOTICA - AUTOMATISMI - RIVELAZIONE INCENDI "
Call Stampa(pag, Lpt)
Printer.CurrentX = 55
Printer.CurrentY = 6
Lpt = "PARTITA IVA/CODICE FISCALE 0170798 034 6"
Call Stampa(pag, Lpt)
Printer.CurrentX = 55
Printer.CurrentY = 7
Lpt = "C.I.A.A. PR172901 ALBO ARTIGIANI 52134"
Call Stampa(pag, Lpt)
Printer.ForeColor = False

dis_modello

Printer.FontName = "Times New Roman"
Printer.FontBold = True
Printer.FontSize = 12
Printer.CurrentX = 7
Printer.CurrentY = 15
Lpt = "PREVENTIVO N."
Call Stampa(pag, Lpt)

Printer.CurrentX = 18
Printer.CurrentY = 17
Lpt = "DEL :"
Call Stampa(pag, Lpt)

Printer.FontBold = False
Printer.FontSize = 7
Printer.CurrentX = 10
Printer.CurrentY = 21.1
Lpt = "CODICE"
Call Stampa(pag, Lpt)

Printer.CurrentX = 35
Printer.CurrentY = 21.1
Lpt = "DESCRIZIONE"
Call Stampa(pag, Lpt)

Printer.CurrentX = 59
Printer.CurrentY = 21.1
Lpt = "U.M."
Call Stampa(pag, Lpt)

Printer.CurrentX = 64
Printer.CurrentY = 21.1
Lpt = "QUANT."
Call Stampa(pag, Lpt)

Printer.CurrentX = 72
Printer.CurrentY = 21.1
Lpt = "PREZZO UNITARIO"
Call Stampa(pag, Lpt)

Printer.CurrentX = 87
Printer.CurrentY = 21.1
Lpt = "IMPORTO"
Call Stampa(pag, Lpt)

Printer.FontSize = 9
Printer.CurrentX = 76
Printer.CurrentY = 53
Lpt = "imponibile"
Call Stampa(pag, Lpt)

Printer.CurrentX = 7
Printer.CurrentY = 53.5
Lpt = "NOTE :"
Call Stampa(pag, Lpt)

Printer.CurrentX = 71
Printer.CurrentY = 55
Lpt = "IVA...........%"
Call Stampa(pag, Lpt)

Printer.CurrentX = 67
Printer.CurrentY = 57
Lpt = "TOTALE DOCUMENTO"
Call Stampa(pag, Lpt)
End If
' Fine Parte dedicata alla stampa del modello su foglio A4

If Not IsNull(DB_CLIENTI.Recordset("NOME";)) Then
indi = DB_CLIENTI.Recordset("NOME";)
Else
indi = ""
End If
i1 = dividi(indi, 39)
indi = Right(indi, Len(indi) - Len(i1))
I2 = dividi(indi, 39)
indi = Right(indi, Len(indi) - Len(I2))
i1 = Trim(i1)
I2 = Trim(I2)
Printer.FontBold = True
Printer.FontSize = 12
Printer.CurrentX = 52
Printer.CurrentY = 10
Call Stampa(pag, i1)
If I2 <> "" Then
Printer.CurrentX = 54
Printer.CurrentY = 11
Call Stampa(pag, I2)
End If

Printer.FontBold = False
Printer.FontSize = 11
Printer.CurrentX = 52
Printer.CurrentY = 12
Lpt = DB_CLIENTI.Recordset("VIA";)
Call Stampa(pag, Lpt)

Printer.CurrentX = 52
Printer.CurrentY = 13
Lpt = DB_CLIENTI.Recordset("CAP";) & ", " & DB_CLIENTI.Recordset("CITTA";) & " " & DB_CLIENTI.Recordset("PROVINCIA";)
Call Stampa(pag, Lpt)

' Printer.FontBold = True
Printer.CurrentX = 52
Printer.CurrentY = 17
Lpt = "P.IVA/Cod.Fisc.: " & DB_CLIENTI.Recordset("PIVA";) & " "
Call Stampa(pag, Lpt)

Printer.CurrentX = 52
Printer.CurrentY = 18
Lpt = "Telefono: " & DB_CLIENTI.Recordset("TEL";) & " - Codice Cliente : " & DB_STOPRE.Recordset("codcli";)
Call Stampa(pag, Lpt)

Printer.FontBold = True
Printer.FontSize = 13
Printer.CurrentX = 28
Printer.CurrentY = 15
Lpt = NORD.Text
Call Stampa(pag, Lpt)
Printer.CurrentX = 28
Printer.CurrentY = 17
Lpt = DATA.Text
Call Stampa(pag, Lpt)
Linea = 23
' Printer.FontName = "Times New Roman"
Printer.FontName = "Courier New"
Printer.FontSize = 10
Printer.FontBold = False

If Not IsNull(DB_STOPRE.Recordset("NOTE";)) Then
nota = DB_STOPRE.Recordset("NOTE";)
Else
nota = ""
End If
d1 = dividi(nota, 50)
nota = Right(nota, Len(nota) - Len(d1))
d2 = dividi(nota, 55)
nota = Right(nota, Len(nota) - Len(d2))
D3 = dividi(nota, 55)
d1 = Trim(d1)
d2 = Trim(d2)
D3 = Trim(D3)
Printer.CurrentX = 15
Printer.CurrentY = 53
Call Stampa(pag, d1)
If d2 <> "" Then
Printer.CurrentX = 10
Printer.CurrentY = 55
Call Stampa(pag, d2)
If D3 <> "" Then
Printer.CurrentX = 10
Printer.CurrentY = 56.5
Call Stampa(pag, D3)
End If
End If

While Not DB_PREV.Recordset.EOF And Not Linea > 51
codart = ""
Casa = ""
CDA = ""
D11 = ""
D21 = ""
D31 = ""
If Not IsNull(DB_PREV.Recordset("CASA";)) Then
Cas = DB_PREV.Recordset("CASA";)
End If

If Not IsNull(DB_PREV.Recordset("CODICE";)) Then
codart = DB_PREV.Recordset("CODICE";)
CDA = Cas & " " & codart
End If
D11 = Mid(CDA, 1, 13)
Printer.CurrentX = 7
Printer.CurrentY = Linea
Call Stampa(pag, D11)
If Len(CDA) > 13 Then
D21 = Mid(CDA, 14, 13)
If Len(D21) > 13 Then
D31 = Mid(CDA, 26, 13)
End If
End If
If Not IsNull(DB_PREV.Recordset("DESCRIZIONE";)) Then
descrizione = DB_PREV.Recordset("DESCRIZIONE";)
Else
descrizione = ""
End If
d1 = dividi(descrizione, 36)
descrizione = Right(descrizione, Len(descrizione) - Len(d1))
d2 = dividi(descrizione, 36)
descrizione = Right(descrizione, Len(descrizione) - Len(d2))
D3 = dividi(descrizione, 36)
descrizione = Right(descrizione, Len(descrizione) - Len(D3))
D4 = dividi(descrizione, 36)
descrizione = Right(descrizione, Len(descrizione) - Len(D4))
D5 = dividi(descrizione, 36)
descrizione = Right(descrizione, Len(descrizione) - Len(D5))
D6 = dividi(descrizione, 36)
descrizione = Right(descrizione, Len(descrizione) - Len(D6))
D7 = dividi(descrizione, 36)
descrizione = Right(descrizione, Len(descrizione) - Len(D7))
D8 = dividi(descrizione, 36)
d1 = Trim(d1)
d2 = Trim(d2)
D3 = Trim(D3)
D4 = Trim(D4)
D5 = Trim(D5)
D6 = Trim(D6)
D7 = Trim(D7)
D8 = Trim(D8)

Printer.CurrentX = 20
Printer.CurrentY = Linea
Call Stampa(pag, d1)

If Not IsNull(DB_PREV.Recordset("UM";)) Then
UMIS = DB_PREV.Recordset("UM";)
Printer.CurrentX = 59
Printer.CurrentY = Linea
Call Stampa(pag, Um)
End If

If Not IsNull(DB_PREV.Recordset("QUANTITA";)) Then
Qta = DB_PREV.Recordset("QUANTITA";)
If Qta - Int(Qta) = 0 Then
lung_sta = Len(Format(Qta, F_MENU.FormatoEuro))
Printer.CurrentX = 68 - lung_sta
Printer.CurrentY = Linea
Call Stampa(pag, (Format(Qty, F_MENU.FormatoEuro)))
Else
lung_sta = Len(Format(Qty, F_MENU.FormatoEuro))
Printer.CurrentX = 68 - lung_sta
Printer.CurrentY = Linea
Call Stampa(pag, Format(Qty, F_MENU.FormatoEuro))
End If
End If

If Not IsNull(DB_PREV.Recordset("PREZZO";)) Then
Prez = DB_PREV.Recordset("PREZZO";)
lung_sta = Len(Format(Prez, F_MENU.FormatoEuro))
colonna = 81 - lung_sta
Printer.CurrentX = colonna
Printer.CurrentY = Linea
Call Stampa(pag, Format(Prez, F_MENU.FormatoEuro))
End If

If Not IsNull(DB_PREV.Recordset("IMPORTO";)) Then
impor = DB_PREV.Recordset("IMPORTO";)
lung_sta = Len(Format(impor, F_MENU.FormatoEuro))
colonna = 94 - lung_sta
Printer.CurrentX = colonna
Printer.CurrentY = Linea
Call Stampa(pag, Format(impor, F_MENU.FormatoEuro))
End If

If d2 <> "" Or D21 <> "" Then
Linea = Linea + 1
If d2 <> "" Then
Printer.CurrentX = 20
Printer.CurrentY = Linea
Call Stampa(pag, d2)
End If
If D21 <> "" Then
Printer.CurrentX = 7
Printer.CurrentY = Linea
Call Stampa(pag, D21)
End If
If D3 <> "" Or D31 <> "" Then
Linea = Linea + 1
If D3 <> "" Then
Printer.CurrentX = 20
Printer.CurrentY = Linea
Call Stampa(pag, D3)
End If
If D31 <> "" Then
Printer.CurrentX = 7
Printer.CurrentY = Linea
Call Stampa(pag, D31)
End If
If D4 <> "" Then
Linea = Linea + 1
Printer.CurrentX = 20
Printer.CurrentY = Linea
Call Stampa(pag, D4)
If D5 <> "" Then
Linea = Linea + 1
Printer.CurrentX = 20
Printer.CurrentY = Linea
Call Stampa(pag, D5)
If D6 <> "" Then
Linea = Linea + 1
Printer.CurrentX = 20
Printer.CurrentY = Linea
Call Stampa(pag, D6)
If D7 <> "" Then
Linea = Linea + 1
Printer.CurrentX = 20
Printer.CurrentY = Linea
Call Stampa(pag, D7)
If D8 <> "" Then
Linea = Linea + 1
Printer.CurrentX = 20
Printer.CurrentY = Linea
Call Stampa(pag, D8)
End If
End If
End If
End If
End If
End If
End If
Linea = Linea + 1
DB_PREV.Recordset.MoveNext
Wend
If DB_PREV.Recordset.EOF Then
fine = True
Printer.CurrentX = 75
Printer.CurrentY = 55
Lpt = CStr(aliq)
Call Stampa(pag, Lpt)

' Da cambiare quando la valuta sarà in EURO
Netto (aliq)
' S_IVA (aliq)
v_netto = t_netto

lung_sta = Len(Format(v_netto, F_MENU.FormatoEuro))
colonna = 94 - lung_sta
Printer.CurrentX = colonna
Printer.CurrentY = 53
Call Stampa(pag, Format(v_netto, F_MENU.FormatoEuro))

V_IVA = T_IVA
lung_sta = Len(Format(V_IVA, F_MENU.FormatoEuro))
colonna = 94 - lung_sta
Printer.CurrentX = colonna
Printer.CurrentY = 55
Call Stampa(pag, Format(V_IVA, F_MENU.FormatoEuro))

v_totale = v_netto + V_IVA
lung_sta = Len(Format(v_totale, F_MENU.FormatoEuro))
colonna = 94 - lung_sta
Printer.CurrentX = colonna
Printer.CurrentY = 57
Call Stampa(pag, Format(v_totale, F_MENU.FormatoEuro))

Printer.CurrentX = 7
Printer.CurrentY = 59
Lpt = "Pagina " & attuale
Call Stampa(pag, Lpt)

Printer.EndDoc
Else
Printer.CurrentX = 7
Printer.CurrentY = 59
Lpt = "Pagina " & attuale
Call Stampa(pag, Lpt)

Printer.CurrentX = 89
Printer.CurrentY = 57
Call Stampa(pag, "Segue";)
If pag = 0 Then
Printer.NewPage
attuale = attuale + 1
Else
attuale = attuale + 1
End If
End If
Wend

F_PREINS.Caption = "Creazione Preventivi"
End If
On Error GoTo 0
st.Visible = False
Call riordino
'Call Calcoli
copiuz.Text = 0
Stamp.Clear
Exit Sub
Nfatt: MsgBox "Devi dirmi Quante Copie Ne Vuoi!!!!", vbExclamation
Exit Sub
errato: MsgBox "il documento citato non e presente oppure presenta un nome errato il nome corretto è 'Capitolato' ", vbExclamation
Resume Next
Resume
End Sub


Private Sub Command8_Click()
Variazione.Visible = False
End Sub

Private Sub Command9_Click()
Dim Ric As Single
Variazione.Visible = False
If var.Text <> "" Then
DB_PREV.Refresh
salva = True
While Not DB_PREV.Recordset.EOF
If Not IsNull(DB_PREV.Recordset("PREZZO";)) Then
Ric = DB_PREV.Recordset("PREZZO";) * var.Text / 100
DB_PREV.Recordset.Edit
DB_PREV.Recordset("PREZZO";) = Format((DB_PREV.Recordset("PREZZOI";) - Ric), F_MENU.FormatoEuro)
' On Error Resume Next
DB_PREV.Recordset("IMPORTO";) = Format((DB_PREV.Recordset("PREZZO";) * DB_PREV.Recordset("QUANTITA";)), F_MENU.FormatoEuro)
DB_PREV.Recordset("SCONTO";) = Format(var.Text, F_MENU.FormatoEuro)
DB_PREV.Recordset.Update
End If
DB_PREV.Recordset.MoveNext
Wend
salva = False
Me.Timer1.Enabled = True

End If
End Sub

Private Sub DB_prev_Validate(Action As Integer, Save As Integer)
If salva = False Then Save = False
End Sub

Private Sub Netto(V_IVA As Double)
DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
DB_PREV.Refresh
t_netto = "0"
T_IVA = "0"
While Not DB_PREV.Recordset.EOF
If Not IsNull(DB_PREV.Recordset("PREZZO";)) Then
t_netto = t_netto + DB_PREV.Recordset("IMPORTO";)
End If
DB_PREV.Recordset.MoveNext
Wend
T_IVA = t_netto * V_IVA / 100
End Sub
'Private Sub S_IVA(V_IVA As Currency)
' DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
' DB_PREV.Refresh
' T_IVA = "0"
' T_IVA = t_netto * V_IVA / 100
'End Sub

Private Sub DBGrid1_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = "g" Or Chr(KeyAscii) = "G" Then DBGrid1.Height = 8500
If Chr(KeyAscii) = "p" Or Chr(KeyAscii) = "P" Then DBGrid1.Height = 2616
End Sub

Private Sub Form_Activate()
flag = True
' Call Calcoli
If BT_elart.Visible = False Then
' Call Calcoli
DB_PREV.DatabaseName = CurDir$ & "\SEA.mdb"
DB_PREV.RecordSource = "select * from db_Prev where numero = " & NORD.Text & " order by ID"
DB_PREV.Refresh
Call Calcoli
flag = False

End If
DB_ARTICOLI.DatabaseName = CurDir$ & "\SEA.mdb"
DB_ARTASS.DatabaseName = CurDir$ & "\SEA.mdb"
DB_STOPRE.DatabaseName = CurDir$ & "\SEA.mdb"
DB_STOPRE.RecordSource = "select * from db_stopre where numero = " & NORD.Text
DB_STOPRE.Refresh
DB_EURO.DatabaseName = CurDir & "\SEA.mdb"
DB_EURO.RecordSource = "db_EURO"
DB_EURO.Refresh

' If L_DocP.Visible Then
' Call riordino
' Else
' Call Calcoli
Call riordino
' End If


' salva = False


' DBGrid1.Columns(0).Visible = False
'DBGrid1.Columns(1).Visible = False
'DBGrid1.Columns(2).Width = 620
' DBGrid1.Columns(2).Alignment = 2
' DBGrid1.Columns(3).Width = 620
' DBGrid1.Columns(3).Alignment = 2
' DBGrid1.Columns(4).Width = 920
' DBGrid1.Columns(4).Alignment = 2
' DBGrid1.Columns(5).Width = 4700
' DBGrid1.Columns(6).Width = 500
' DBGrid1.Columns(6).Alignment = 2
' DBGrid1.Columns(7).Width = 723
' DBGrid1.Columns(7).Alignment = 2
' DBGrid1.Columns(8).Width = 680
' DBGrid1.Columns(9).Width = 680
' DBGrid1.Columns(10).Width = 680
' DBGrid1.Columns(11).Width = 680
' DBGrid1.Columns(12).Width = 680
' DBGrid1.Columns(13).Width = 680
' DBGrid1.Columns(14).Width = 550
' DBGrid1.Columns(15).Width = 550
' DBGrid1.Columns(16).Width = 680
End Sub

Private Sub Form_Deactivate()
Dim IMPO, IVA, parz As Double
IMPO = 0
DB_PREV.Refresh
While Not DB_PREV.Recordset.EOF
If Not IsNull(DB_PREV.Recordset("PREZZO";)) And Not IsNull(DB_PREV.Recordset("QUANTITA";)) And Not IsNull(DB_PREV.Recordset("IVA";)) Then
IMPO = IMPO + DB_PREV.Recordset("IMPORTO";)
End If
DB_PREV.Recordset.MoveNext
Wend
DB_STOPRE.Recordset.Edit
DB_STOPRE.Recordset("IMPONIBILE";) = Format(IMPO, F_MENU.FormatoEuro)
DB_STOPRE.Recordset.Update

End Sub


Private Sub Form_Load()
Dim X As Integer
Dim Y As Integer
X = (Screen.Width - 11400) / 2
Y = (Screen.Height - 8004) / 2
F_PREINS.Move X, Y
End Sub

Private Sub Form_Resize()
DBGrid1.Width = Me.Width - 250

End Sub
Private Sub Form_Unload(Cancel As Integer)
Call Form_Deactivate
End
End Sub

Private Sub IVA_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If IVA.Text <> "" And Not IsNumeric(IVA.Text) Then
tipo_finmsg = 0
Msg = "La Quantità non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo";) = 1 Then
End If
IVA.SetFocus
End If
End Sub

Private Sub MANOD_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If MANOD.Text <> "" And Not IsNumeric(MANOD.Text) Then
tipo_finmsg = 0
Msg = "Il prezzo non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo";) = 1 Then
End If
MANOD.SetFocus
End If
End Sub

Private Sub mnuesci_Click()
Bt_addnota.Visible = True
BT_parz.Visible = True
BT_newvoce.Visible = True
BT_elart.Visible = False
L9.Visible = False
L10.Visible = False
Costo.Visible = False
Ricarico.Visible = False
BT_modvoce.Visible = True
BT_cancvoce.Visible = True
BT_insvoce.Visible = False
BT_annvoce.Visible = False
BT_forn.Visible = True
F_PREINS.Hide
F_MENU.Show
End Sub

Private Sub mnuins_Click()
F_MENU.DATA.Text = Date
F_MENU.DB_STOPRE.DatabaseName = CurDir & "\SEA.mdb"
F_MENU.DB_STOPRE.RecordSource = "select * from db_stopre order by numero"
F_MENU.DB_STOPRE.Refresh
If Not F_MENU.DB_STOPRE.Recordset.EOF Then
F_MENU.DB_STOPRE.Recordset.MoveLast
F_MENU.NORD.Text = DB_STOPRE.Recordset("numero";) + 1
Else
F_MENU.NORD.Text = 1
End If
F_MENU.Prev.Visible = True
F_MENU.NORD.Visible = True
F_MENU.dat.Visible = True
F_MENU.DATA.Visible = True
F_MENU.num.Visible = True
F_MENU.V_IVA.Visible = True
F_MENU.IVA.Visible = True
F_MENU.BtIns.Visible = True
F_MENU.Btann.Visible = True
Bt_addnota.Visible = True
BT_parz.Visible = True
BT_newvoce.Visible = True
BT_elart.Visible = False
L9.Visible = False
L10.Visible = False
Costo.Visible = False
Ricarico.Visible = False
BT_modvoce.Visible = True
BT_cancvoce.Visible = True
BT_insvoce.Visible = False
BT_annvoce.Visible = False
BT_forn.Visible = True
F_PREINS.Hide
F_MENU.Show
End Sub

Private Sub mnuric_Click()
Bt_addnota.Visible = True
BT_parz.Visible = True
BT_newvoce.Visible = True
BT_elart.Visible = False
L9.Visible = False
L10.Visible = False
Costo.Visible = False
Ricarico.Visible = False
BT_modvoce.Visible = True
BT_cancvoce.Visible = True
BT_insvoce.Visible = False
BT_annvoce.Visible = False
BT_forn.Visible = True
F_PREINS.Hide
F_STOPRE.Show
End Sub

Private Sub nump_Change()
If nump.Text <> "" Then tutte.Value = 0
End Sub

Private Sub nump_GotFocus()
If nump.Text <> "" Then tutte.Value = 0
End Sub

Private Sub Prscont_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If Prscont.Text <> "" And Not IsNumeric(Prscont.Text) Then
tipo_finmsg = 0
Msg = "La Quantità non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo";) = 1 Then
End If
Prscont.SetFocus
End If
End Sub

Private Sub Prunit_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If Prunit.Text <> "" And Not IsNumeric(Prunit.Text) Then
tipo_finmsg = 0
Msg = "Il prezzo non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo";) = 1 Then
End If
Prunit.SetFocus
End If
If Prunit.Text <> "" And IsNumeric(Prunit.Text) Then
Sconto.Text = 0
Prscont.Text = Prunit.Text
IVA.Text = DB_STOPRE.Recordset("IVA";)
End If
End Sub


Private Sub Qty_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If Qty.Text <> "" And Not IsNumeric(Qty.Text) Then
tipo_finmsg = 0
Msg = "La Quantità non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo";) = 1 Then
End If
Qty.SetFocus
End If
End Sub


Private Sub r_Click()
F_PREINS.Hide
F_STOPRE.Show
F_STOPRE.Codice_Cliente.Visible = True
'Call F_STOPRE.ordCli_Click

'DB_STOPRE.RecordSource = "select * from db_stopre where codcli=" & F_STOPRE.cliente.Text
' DB_STOPRE.Refresh
' If DB_STOPRE.Recordset.EOF Then
' Call messaggio
' End If
'Call riord

End Sub

Private Sub Sconto_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
Dim sc As Currency
If Sconto.Text <> "" And Not IsNumeric(Sconto.Text) Then
tipo_finmsg = 0
Msg = "La Quantità non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo";) = 1 Then
End If
Sconto.SetFocus
Else
If Sconto.Text <> "" And Prunit <> "" Then
sc = Prunit.Text * Sconto.Text / 100
Prscont = Prunit - sc
End If
End If
End Sub

Private Sub Timer1_Timer()
Form_Activate
'Call Calcoli
Me.Timer1.Enabled = False
End Sub

Private Sub tutte_Click()
If tutte.Value = 1 Then
nump.Text = ""
End If
End Sub

Private Sub UM_LostFocus()
Um.Text = UCase(Um.Text)
End Sub

Private Sub Var_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If var.Text <> "" And Not IsNumeric(var.Text) Then
tipo_finmsg = 0
Msg = "La Quantità non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo";) = 1 Then
End If
var.SetFocus
End If
End Sub


questo e il codice dove prelevo l'articolo

Option Compare Text
Dim flag, flag1 As Boolean
Dim pos_db, cont, pos_ric As Integer
Dim salva As Boolean

Private Sub BT_CANCELLA_Click()
Dim Msg As String
Dim tipo_finmsg As Integer
If Not DB_ARTICOLI.Recordset.EOF Then
tipo_finmsg = 4
Msg = "Conferma la Cancellazione dei dati di" & Chr$(13)
Msg = Msg & DB_ARTICOLI.Recordset("CASA";) & " " & DB_ARTICOLI.Recordset("CODICE";) & " ?"
If MsgBox(Msg, tipo_finmsg, "Cancella Dati Articolo";) = 6 Then
salva = True
DB_ARTICOLI.Recordset.Delete
salva = False
DB_ARTICOLI.Recordset.MoveNext
If DB_ARTICOLI.Recordset.EOF Then
DB_ARTICOLI.Refresh
If Not DB_ARTICOLI.Recordset.EOF Then DB_ARTICOLI.Recordset.MoveLast
End If
flag = False
flag1 = False
ric_casa.Text = ""
Ric_cod.Text = ""
ric_des.Text = ""
flag = True
flag1 = True
DB_ART.Refresh
End If
End If
End Sub

Private Sub BT_pann_Click()
BT_pins.Visible = False
BT_pann.Visible = False
BT_REGMOD.Visible = True
BT_CANCELLA.Visible = True
mnuart.Enabled = True
mnumenu.Enabled = True
F_ARTRMO.Caption = "Ricerca e Modifica dati Articoli Singoli"
If L_DocP.Visible Then
F_ARTRMO.Hide
F_PREINS.Show
End If
If L_DocB.Visible Then
F_ARTRMO.Hide
F_BOLINS.Show
End If
If L_DocF.Visible Then
F_ARTRMO.Hide
F_FATINS.Show
End If
If L_DocR.Visible Then
F_ARTRMO.Hide
F_RICINS.Show
End If
L_DocF.Visible = False
L_DocP.Visible = False
L_DocB.Visible = False
L_DocR.Visible = False
End Sub

Private Sub BT_pins_Click()
If Not DB_ARTICOLI.Recordset.EOF Then
BT_pins.Visible = False
BT_pann.Visible = False
BT_REGMOD.Visible = True
BT_CANCELLA.Visible = True
mnuart.Enabled = True
mnumenu.Enabled = True
F_ARTRMO.Caption = "Ricerca e Modifica dati Articoli Singoli"
If L_cantieri.Visible Then
With F_CANTINS
.DB_CANT.DatabaseName = CurDir & "\SEA.mdb"
.DB_CANT.RecordSource = "select * from db_cant where CANT = " & .NORD.Text & " and com = " & .com.Text
.DB_CANT.Refresh
If Not .DB_CANT.Recordset.EOF Then
.DB_CANT.Recordset.MoveLast
End If
.Casa = Casa.Text
.Codice = Codice.Text
.Des = Des.Text
.Um = Um.Text
.Costo = Prezzo.Text
.Ricarico = Ricarico.Text
.Prunit = DB_ARTICOLI.Recordset("LISTINO";)
.Prscont = DB_ARTICOLI.Recordset("LISTINO";)
.IVA = IVA.Text
.C0.Visible = True
.R0.Visible = True
.Costo.Visible = True
.Ricarico.Visible = True
.Qty.Text = 1
.Sconto.Text = 0
End With
F_ARTRMO.Hide
F_CANTINS.Show
End If
If L_DocP.Visible Then
With F_PREINS
.DB_PREV.DatabaseName = CurDir & "\SEA.mdb"
.DB_PREV.RecordSource = "select * from db_Prev where numero =" & .NORD.Text '& " order by ID"
.DB_PREV.Refresh
If Not .DB_PREV.Recordset.EOF Then
.DB_PREV.Recordset.MoveLast
End If
.Casa = Casa.Text
.Codice = Codice.Text
.Des = Des.Text
.Um = Um.Text
.Costo = Prezzo.Text
.Ricarico = Ricarico.Text
.Prunit = DB_ARTICOLI.Recordset("LISTINO";)
.Prscont = DB_ARTICOLI.Recordset("LISTINO";)
.IVA = IVA.Text
.L9.Visible = True
.L10.Visible = True
.Costo.Visible = True
.Ricarico.Visible = True
.Qty.Text = 1
.Sconto.Text = 0
End With
F_ARTRMO.Hide
F_PREINS.Show
End If
If L_DocF.Visible Then
With F_FATINS
.DB_FATTURE.DatabaseName = CurDir & "\SEA.mdb"
.DB_FATTURE.RecordSource = "select * from db_fatture where numero = " & .NORD.Text '& "order By ID"
.DB_FATTURE.Refresh
If Not .DB_FATTURE.Recordset.EOF Then
.DB_FATTURE.Recordset.MoveLast
End If
.Casa = Casa.Text
.Codice = Codice.Text
.Des = Des.Text
.Um = Um.Text
.Costo = Prezzo.Text
.Ricarico = Ricarico.Text
.Prunit = DB_ARTICOLI.Recordset("LISTINO";)
.Prscont = DB_ARTICOLI.Recordset("LISTINO";)
.IVA = IVA.Text
.L9.Visible = True
.L10.Visible = True
.Costo.Visible = True
.Ricarico.Visible = True
.Qty.Text = 1
.Sconto.Text = 0
End With
F_ARTRMO.Hide
F_FATINS.Show
End If
If L_DocFele.Visible Then
With F_FATTELE
.DB_FATTELE.DatabaseName = CurDir & "\SEA.mdb"
.DB_FATTELE.RecordSource = "select * from db_fattele where numero = " & .NORD.Text '& "order By ID"
.DB_FATTELE.Refresh
If Not .DB_FATTELE.Recordset.EOF Then
.DB_FATTELE.Recordset.MoveLast
End If
.Casa = Casa.Text
.Codice = Codice.Text
.Des = Des.Text
.Um = Um.Text
.Costo = Prezzo.Text
.Ricarico = Ricarico.Text
.Prunit = DB_ARTICOLI.Recordset("LISTINO";)
.Prscont = DB_ARTICOLI.Recordset("LISTINO";)
.IVA = IVA.Text
.L9.Visible = True
.L10.Visible = True
.Costo.Visible = True
.Ricarico.Visible = True
.Qty.Text = 1
.Sconto.Text = 0
End With
F_ARTRMO.Hide
F_FATTELE.Show
End If
If L_DocB.Visible Then
With F_BOLINS
.DB_BOLLE.DatabaseName = CurDir & "\SEA.mdb"
.DB_BOLLE.RecordSource = "select * from db_BOLLE where numero = " & .NORD.Text '& "order by ID"
.DB_BOLLE.Refresh
If Not .DB_BOLLE.Recordset.EOF Then
.DB_BOLLE.Recordset.MoveLast
End If
.Casa = Casa.Text
.Codice = Codice.Text
.Des = Des.Text
.Um = Um.Text
.Costo = Prezzo.Text
.Ricarico = Ricarico.Text
.Prunit = DB_ARTICOLI.Recordset("LISTINO";)
.Prscont = DB_ARTICOLI.Recordset("LISTINO";)
.IVA = IVA.Text
.L9.Visible = True
.L10.Visible = True
.Costo.Visible = True
.Ricarico.Visible = True
.Qty.Text = 1
.Sconto.Text = 0
End With
F_ARTRMO.Hide
F_BOLINS.Show
End If
If L_DocR.Visible Then
With F_RICINS
.DB_RICEVUTE.DatabaseName = CurDir & "\SEA.mdb"
.DB_RICEVUTE.RecordSource = "select * from db_ricevute where numero = " & .NORD.Text
.DB_RICEVUTE.Refresh
If Not .DB_RICEVUTE.Recordset.EOF Then
.DB_RICEVUTE.Recordset.MoveLast
End If
.Casa = Casa.Text
.Codice = Codice.Text
.Des = Des.Text
.Um = Um.Text
.Costo = Prezzo.Text
.Ricarico = Ricarico.Text
.Prunit = DB_ARTICOLI.Recordset("LISTINO";)
.Prscont = DB_ARTICOLI.Recordset("LISTINO";)
.IVA = IVA.Text
.L9.Visible = True
.L10.Visible = True
.Costo.Visible = True
.Ricarico.Visible = True
.Qty.Text = 1
.Sconto.Text = 0
End With
F_ARTRMO.Hide
F_RICINS.Show
End If
L_DocF.Visible = False
L_DocP.Visible = False
L_DocB.Visible = False
L_DocR.Visible = False
L_cantieri.Visible = False
End If
End Sub

Private Sub BT_REGMOD_Click()
Dim Msg As String
Dim tipo_finmsg As Integer
Dim esegui As Boolean
Dim pos As Integer
If Not DB_ARTICOLI.Recordset.EOF Then
esegui = True
pos = DB_ARTICOLI.Recordset.AbsolutePosition
DB_ART.Refresh
While (Not DB_ART.Recordset.EOF) And esegui
If DB_ART.Recordset("CASA";) = Casa.Text And DB_ART.Recordset("CODICE";) = Codice.Text And DB_ART.Recordset.AbsolutePosition <> pos Then
esegui = False
Else
DB_ART.Recordset.MoveNext
End If
Wend
If esegui Then
salva = True
DB_ARTICOLI.Recordset.Edit
If Prezzo.Text <> "" And Ricarico.Text <> "" Then
If DB_ARTICOLI.Recordset("COSTO";) <> Prezzo.Text Or DB_ARTICOLI.Recordset("Ricarico";) <> Ricarico.Text Or DB_ARTICOLI.Recordset("iva";) <> IVA.Text Then
DB_ARTICOLI.Recordset("data";) = Date
End If
DB_ARTICOLI.Recordset("LISTINO";) = Format((Prezzo.Text + (Prezzo.Text * Ricarico.Text / 100)), F_MENU.FormatoEuro)
DB_ARTICOLI.Recordset("TOTIVA";) = Format(((DB_ARTICOLI.Recordset("LISTINO";) * DB_ARTICOLI.Recordset("IVA";) / 100)), F_MENU.FormatoEuro)
DB_ARTICOLI.Recordset("Totale";) = Format((DB_ARTICOLI.Recordset("LISTINO";) + (DB_ARTICOLI.Recordset("TOTIVA";))), F_MENU.FormatoEuro)
End If
DB_ARTICOLI.Recordset.Update
salva = False
Else
tipo_finmsg = 0
Msg = "Il Codice della casa " & DB_ARTICOLI.Recordset("CASA";) & " è già esistente."
Msg = Msg & " La modifica non può essere registrata"
If MsgBox(Msg, tipo_finmsg, "Modifica Dati Articoli";) = 1 Then
Casa.SetFocus
End If
End If
End If
End Sub

Private Sub BT_RIC_Click()
Dim pos_str, tipo_finmsg As Integer
Dim var_db, Msg As String
Dim trovato As Boolean
If Not DB_ARTICOLI.Recordset.EOF Then
If ric_des.Text <> "" Then
trovato = False
pos_db = DB_ARTICOLI.Recordset.AbsolutePosition
cont = 1
While cont < 3 And Not trovato
While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato And cont < 3
var_db = DB_ARTICOLI.Recordset("DESCRIZIONE";)
pos_str = InStr(var_db, ric_des.Text)
If pos_str > 0 Then
trovato = True
Else
DB_ARTICOLI.Recordset.MoveNext
If DB_ARTICOLI.Recordset.AbsolutePosition = pos_db Then
cont = 3
End If
End If
Wend
If DB_ARTICOLI.Recordset.EOF Then
DB_ARTICOLI.Refresh
cont = cont + 1
End If
Wend
If Not trovato Then
tipo_finmsg = 0
Msg = "ATTENZIONE: La parola non è presente in elenco"
If MsgBox(Msg, tipo_finmsg, "Ricerca Articolo";) = 1 Then
ric_des.SetFocus
End If
Else
BT_RIC.Visible = False
succ.Visible = True
BT_stop.Visible = True
ric_des.Locked = True
End If
End If
End If
End Sub

Private Sub BT_STOP_Click()
BT_stop.Visible = False
succ.Visible = False
BT_RIC.Visible = True
ric_des.Locked = False
End Sub

Private Sub carsca_Click()
F_ARTRMO.Hide
F_ARTINV.Show
End Sub

Private Sub Casa_LostFocus()
Casa.Text = UCase(Casa.Text)
End Sub
Private Sub codice_LostFocus()
Codice.Text = UCase(Codice.Text)
End Sub
Private Sub DB_ARTICOLI_Validate(Action As Integer, Save As Integer)
If salva = False Then Save = False
End Sub

Private Sub Form_Activate()
Dim sdir As String
sdir = CurDir
DB_ARTICOLI.DatabaseName = sdir & "\sea.mdb"
DB_ARTICOLI.RecordSource = "select * from db_articoli order by casa,codice"
DB_ARTICOLI.Refresh
DB_ART.DatabaseName = sdir & "\sea.mdb"
DB_ART.RecordSource = "select * from db_articoli order by casa,codice"
DB_ART.Refresh


DBGrid1.Columns(0).Width = 500
DBGrid1.Columns(0).Alignment = 0
DBGrid1.Columns(1).Width = 920
DBGrid1.Columns(1).Alignment = 0
DBGrid1.Columns(2).Width = 3500
DBGrid1.Columns(2).Alignment = 0
DBGrid1.Columns(3).Width = 380
DBGrid1.Columns(3).Alignment = 2
DBGrid1.Columns(4).Width = 870
DBGrid1.Columns(4).Alignment = 0
DBGrid1.Columns(5).Width = 750
DBGrid1.Columns(5).Alignment = 0
DBGrid1.Columns(6).Width = 750
DBGrid1.Columns(6).Alignment = 0
DBGrid1.Columns(7).Width = 750
DBGrid1.Columns(7).Alignment = 0
DBGrid1.Columns(8).Width = 750
DBGrid1.Columns(8).Alignment = 0
DBGrid1.Columns(9).Width = 700
DBGrid1.Columns(9).Alignment = 0
DBGrid1.Columns(10).Width = 750
DBGrid1.Columns(10).Alignment = 2
DBGrid1.Columns(11).Width = 750
DBGrid1.Columns(11).Alignment = 0
DBGrid1.Columns(12).Width = 750
DBGrid1.Columns(12).Alignment = 0
DBGrid1.Columns(13).Width = 750
DBGrid1.Columns(13).Alignment = 0
DBGrid1.Columns(14).Width = 1000
DBGrid1.Columns(14).Alignment = 0

DBGrid1.SetFocus
salva = False
flag = False
flag1 = True
ric_casa = ""
Ric_cod = ""
ric_des = ""
flag = True
flag1 = True
BT_stop.Visible = False
succ.Visible = False
BT_RIC.Visible = True
ric_des.Locked = False
End Sub

Private Sub Form_Load()
Dim X As Integer
Dim Y As Integer
X = (Screen.Width - 11400) / 2
Y = (Screen.Height - 8004) / 2
F_ARTRMO.Move X, Y
End Sub

Private Sub Form_Resize()
DBGrid1.Width = Me.Width - 250

End Sub

Private Sub Form_Unload(Cancel As Integer)
End
End Sub

Private Sub Giacenza_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If Giacenza.Text <> "" And Not IsNumeric(Giacenza.Text) Then
tipo_finmsg = 0
Msg = "La giacenza non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli";) = 1 Then
End If
Giacenza.SetFocus
End If
End Sub

Private Sub IVA_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If IVA.Text <> "" And Not IsNumeric(IVA.Text) Then
tipo_finmsg = 0
Msg = "L'IVA non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli";) = 1 Then
End If
IVA.SetFocus
End If
End Sub

Private Sub list_Click()
F_ARTRMO.Hide
F_ARTAGG.Show
End Sub

Private Sub mnuesci_Click()
F_ARTRMO.Hide
F_MENU.Show
End Sub

Private Sub mnuins_Click()
F_ARTRMO.Hide
F_ARTINS.Show
End Sub

Private Sub modtut_Click()
F_ARTRMO.Hide
F_ARTMTU.Show
End Sub

Private Sub Prezzo_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If Prezzo.Text <> "" And Not IsNumeric(Prezzo.Text) Then
tipo_finmsg = 0
Msg = "Il prezzo non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli";) = 1 Then
End If
Prezzo.SetFocus
End If
End Sub

Private Sub ric_casa_Change()
Dim trovato As Boolean
Dim var_db, var_ins As String
Dim lung As Integer
If flag1 Then
flag = False
Ric_cod.Text = ""
flag = True
DB_ARTICOLI.Refresh
var_ins = ric_casa.Text
lung = Len(var_ins)
While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato
var_db = DB_ARTICOLI.Recordset("CASA";)
var_db = Left(var_db, lung)
If var_db = var_ins Then
trovato = True
ric_casa.SetFocus
Else
DB_ARTICOLI.Recordset.MoveNext
End If
Wend
If DB_ARTICOLI.Recordset.EOF Then
DB_ARTICOLI.Refresh
ric_casa.SetFocus
End If
pos_ric = DB_ARTICOLI.Recordset.AbsolutePosition
End If
End Sub

Private Sub ric_cod_Change()
Dim trovato As Boolean
Dim var_db, var_ins As String
Dim lung, pos, I As Integer
If flag Then
var_ins = Ric_cod.Text
If ric_casa = "" Then
DB_ARTICOLI.Refresh
pos_ric = DB_ARTICOLI.Recordset.AbsolutePosition
End If
lung = Len(var_ins)
While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato
If Ric_cod = "" Then
DB_ARTICOLI.Refresh
For I = 1 To pos_ric
DB_ARTICOLI.Recordset.MoveNext
Next I
Ric_cod.SetFocus
End If
var_db = DB_ARTICOLI.Recordset("CODICE";)
var_db = Left(var_db, lung)
If var_db = var_ins Then
trovato = True
Ric_cod.SetFocus
Else
DB_ARTICOLI.Recordset.MoveNext
End If
Wend
If DB_ARTICOLI.Recordset.EOF Then
If ric_casa = "" Then
DB_ARTICOLI.Refresh
Ric_cod.SetFocus
Else
DB_ARTICOLI.Refresh
For I = 1 To pos_ric
DB_ARTICOLI.Recordset.MoveNext
Next I
Ric_cod.SetFocus
End If
End If
End If
End Sub

Private Sub Ricarico_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
If Ricarico.Text <> "" And Not IsNumeric(Ricarico.Text) Then
tipo_finmsg = 0
Msg = "Il ricarico non è in formato numerico"
If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli";) = 1 Then
End If
Ricarico.SetFocus
End If
End Sub

Private Sub sta_Click()
F_ARTRMO.Hide
F_ARTSTA.Show
End Sub

Private Sub succ_Click()
Dim pos_str, tipo_finmsg, I As Integer
Dim var_db, Msg As String
Dim trovato As Boolean
trovato = False
If Not (DB_ARTICOLI.Recordset.AbsolutePosition = 1 And cont = 2) Then
DB_ARTICOLI.Recordset.MoveNext
End If
While cont < 3 And Not trovato
While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato And cont < 3
If DB_ARTICOLI.Recordset.AbsolutePosition >= pos_db And cont = 2 Then
cont = 3
End If
var_db = DB_ARTICOLI.Recordset("DESCRIZIONE";)
pos_str = InStr(var_db, ric_des.Text)
If pos_str > 0 Then
trovato = True
Else
DB_ARTICOLI.Recordset.MoveNext
End If
Wend
If DB_ARTICOLI.Recordset.EOF Then
DB_ARTICOLI.Refresh
cont = cont + 1
End If
Wend
If cont >= 3 Then
tipo_finmsg = 0
Msg = "ATTENZIONE: Tutte le occorrenze della parola sono state trovate"
If MsgBox(Msg, tipo_finmsg, "Ricerca Articolo";) = 1 Then
ric_des.SetFocus
BT_stop.Visible = False
succ.Visible = False
BT_RIC.Visible = True
ric_des.Locked = False
End If
End If
End Sub



spero qualcuno mi possa riuscire a dare una mano grazie a tutti comunque per la cortesia e la
celerita delle risposte



26/06/22 17:36
nessuno
Intanto il codice va riportato tra tag code o non si capisce nulla.

E poi dovresti dire di quale chiamata e sub stai parlando. O ce lo inventiamo?

A che serve tutto quel (pessimo) codice se il problema non dici dove sta?
Ultima modifica effettuata da nessuno 26/06/22 17:52
Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.
26/06/22 21:52
islington
ciao scusami, non volevo offenderti, io i tag li ho messi
se mi dici cos' non so perche non li ha presi
provero a rimetterli

la chiamata che rompe le scatole è

call calcoli




Option Compare Text
Dim salva As Boolean
Dim flag As Boolean
Dim T_IVA As Double, t_netto As Double
Dim attuale As Integer
#If Win32 Then

      Private Declare Function SetBkMode Lib "gdi32" _
      (ByVal hDC As Long, ByVal nBkMode As Long) As Long

      Private iBKMode As Long

   #Else

      Private Declare Function SetBkMode Lib "GDI" (ByVal hDC As Integer _
       , ByVal nBkMode As Integer) As Integer

      Private iBKMode As Integer

   #End If

      Private Const TRANSPARENT = 1
      Private Const OPAQUE = 2
Public Sub riordino()
    
   ' DB_PREV.Refresh
   ' DB_PREV.Recordset.MoveLast

    DBGrid1.Columns(0).Visible = False
    DBGrid1.Columns(1).Visible = False
    DBGrid1.Columns(2).Visible = False
    DBGrid1.Columns(3).Width = 720
    DBGrid1.Columns(3).Alignment = 2
    DBGrid1.Columns(4).Width = 1120
    DBGrid1.Columns(4).Alignment = 2
    DBGrid1.Columns(5).Width = 5900
    DBGrid1.Columns(6).Width = 600
    DBGrid1.Columns(6).Alignment = 2
    DBGrid1.Columns(7).Width = 1100
    DBGrid1.Columns(7).Alignment = 2
    DBGrid1.Columns(8).Width = 1000
    DBGrid1.Columns(9).Width = 1000
    DBGrid1.Columns(10).Width = 1000
    DBGrid1.Columns(11).Width = 1000
    DBGrid1.Columns(12).Width = 1000
    DBGrid1.Columns(13).Width = 1000
    DBGrid1.Columns(14).Width = 1000
    DBGrid1.Columns(15).Width = 700
    DBGrid1.Columns(16).Width = 1000
'    DBGrid1.SetFocus


End Sub
Function dividi(descr As String, l As Integer) As String
Dim cont As Integer
Dim lung As Integer
Dim spazio As String
    ' Lunghezza stringa restituita
    lung = l
    If Len(descr) <= lung Then
        dividi = descr
    Else
        cont = lung
        spazio = Mid(descr, lung, 1)
        While Not spazio = " "
            cont = cont - 1
            spazio = Mid(descr, cont, 1)
        Wend
        dividi = Mid(descr, 1, cont)
    End If
End Function

Private Sub CANCELLA()
    Des.Text = ""
    Um.Text = ""
    Prunit.Text = ""
    Prscont.Text = ""
    Sconto.Text = ""
    IVA.Text = ""
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
End Sub

Private Sub Stampa(pagina As Integer, stringa As String)
    If pagina = 0 Or pagina = attuale Then
        Printer.Print stringa
    End If
End Sub

Private Sub Bt_addnota_Click()
    If Not IsNull(DB_STOPRE.Recordset("NOTE")) Then
        Note.Text = DB_STOPRE.Recordset("NOTE")
    Else
        Note.Text = ""
    End If
    Note.Visible = True
    L_note.Visible = True
    BT_insnota.Visible = True
    Bt_annota.Visible = True
    BT_parz.Visible = False
    BT_forn.Visible = False
    BT_var.Visible = False
    Note.SetFocus
    Bt_addnota.Visible = False
    Call riordino
    'Call Calcoli
End Sub


Private Sub BT_AnNota_Click()
    Note.Visible = False
    L_note.Visible = False
    BT_insnota.Visible = False
    Bt_annota.Visible = False
    BT_parz.Visible = True
    BT_var.Visible = True
    Bt_addnota.Visible = True
    BT_forn.Visible = True
    DBGrid1.SetFocus
    Call riordino
    'Call Calcoli
End Sub

Private Sub BT_annvoce_Click()
    BT_var.Visible = True
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_newvoce.Visible = True
    BT_elart.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_insvoce.Visible = False
    BT_sta.Visible = True
    scelta.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    flag = False
    DB_PREV.Recordset.MoveLast
    DB_PREV.Recordset.Delete
    DB_PREV.Recordset.MoveLast
    DBGrid1.SetFocus
    Call riordino
    'Call Calcoli
End Sub

Private Sub Bt_cancVoce_Click()
Dim Msg As String
Dim tipo_finmsg As Integer
    If Not DB_PREV.Recordset.EOF Then
        tipo_finmsg = 4
        Msg = "Conferma la Cancellazione della voce dal documento ?"
        If MsgBox(Msg, tipo_finmsg, "Cancella da Documento") = 6 Then
            DB_PREV.Recordset.Delete
            DB_PREV.Recordset.MoveNext
            If DB_PREV.Recordset.EOF Then
                DB_PREV.Refresh
                If Not DB_PREV.Recordset.EOF Then DB_PREV.Recordset.MoveLast
            End If
            DBGrid1.SetFocus
           ' Me.Timer1.Enabled = True
           Call Calcoli
        Call riordino
          
        End If
    End If
    'Call riordino
    'Call Calcoli
End Sub

Private Sub BT_elart_Click()
    scelta.ZOrder 0
    scelta.Visible = True
End Sub

Private Sub BT_forn_Click()
    F_CAMFOR.cliente = DB_STOPRE.Recordset("CLIENTE")
    F_CAMFOR.NORD = NORD.Text
    F_CAMFOR.DATA = DATA.Text
    F_PREINS.Hide
    F_CAMFOR.Show
End Sub

Private Sub BT_insnota_Click()
    DB_STOPRE.Recordset.Edit
    DB_STOPRE.Recordset("NOTE") = Note.Text
    DB_STOPRE.Recordset.Update
    Note.Visible = False
    L_note.Visible = False
    BT_insnota.Visible = False
    Bt_annota.Visible = False
    BT_parz.Visible = True
    BT_var.Visible = True
    BT_forn.Visible = True
    Bt_addnota.Visible = True
    DBGrid1.SetFocus
End Sub

Private Sub BT_insvoce_Click()
    IVA.Text = DB_STOPRE.Recordset("IVA")
    salva = True
    DB_PREV.Recordset.Edit
    DB_PREV.Recordset("NUMERO") = NORD.Text
    If Qty.Text <> "" And Prscont.Text <> "" Then
        DB_PREV.Recordset("IMPORTO") = Format((Qty.Text * Prscont.Text), F_MENU.FormatoEuro)
        End If
     If Qty.Text <> "" And UDC.Text <> "" Then
         DB_PREV.Recordset("Tot_UDC") = Format((Qty.Text * UDC.Text), F_MENU.FormatoEuro)
          End If
        If Qty.Text <> "" And MANOD.Text <> "" Then
         DB_PREV.Recordset("TMANOD") = Format((Qty.Text * MANOD.Text), F_MENU.FormatoEuro)
          End If
          
    DB_PREV.Recordset.Update
    salva = False
    BT_var.Visible = True
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_sta.Visible = True
    BT_newvoce.Visible = True
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_elart.Visible = False
    scelta.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_insvoce.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    DB_PREV.Recordset.MoveLast
    DBGrid1.SetFocus
    flag = False
    
    Call Calcoli
   Call riordino
    
   ' DBGrid1.SetFocus
        End Sub


Private Sub BT_modvoce_Click()
    If Not DB_PREV.Recordset.EOF Then
        salva = True
        DB_PREV.Recordset.Edit
        If Qty.Text <> "" And Prscont.Text <> "" Then
            DB_PREV.Recordset("IMPORTO") = Format((Qty.Text * Prscont.Text), F_MENU.FormatoEuro)
            End If
        If Qty.Text <> "" And UDC.Text <> "" Then
            DB_PREV.Recordset("TOT_UDC") = Format((Qty.Text * UDC.Text), F_MENU.FormatoEuro)
         End If
             If Qty.Text <> "" And MANOD.Text <> "" Then
            DB_PREV.Recordset("TMANOD") = Format((Qty.Text * MANOD.Text), F_MENU.FormatoEuro)
         End If
        
       DB_PREV.Recordset.Update
            salva = False
        DBGrid1.SetFocus
    End If
    Call Calcoli
    Call riordino
    
End Sub


Private Sub BT_newvoce_Click()
   ' flag = True
    DB_PREV.Recordset.AddNew
    DB_PREV.Recordset("NUMERO") = NORD.Text
    DB_PREV.Recordset.Update
    'con il seguente comando aggiunge voce sempre e solo alla fine del database
    DB_PREV.Recordset.MoveLast
    Casa.Text = ""
    Codice.Text = ""
    Des.Text = ""
    Um.Text = ""
    UDC.Text = ""
    TOT_UDC.Text = ""
    MANOD.Text = ""
    TMANOD.Text = ""
    Prunit.Text = ""
    Prscont.Text = ""
    Sconto.Text = ""
    IVA.Text = ""
    BT_var.Visible = False
    BT_elart.Visible = True
    BT_sta.Visible = False
    BT_insnota.Visible = False
   flag = True
    Bt_annota.Visible = False
    L_note.Visible = False
    Note.Visible = False
    Bt_addnota.Visible = False
    BT_parz.Visible = False
    BT_newvoce.Visible = False
    BT_insvoce.Visible = True
    BT_annvoce.Visible = True
    BT_modvoce.Visible = False
    BT_forn.Visible = False
    BT_cancvoce.Visible = False
    Call riordino
    'Call Calcoli
    Casa.SetFocus
  
End Sub

Private Sub Calcoli()
Dim tipo_finmsg As String
Dim Msg As String
Dim IMPO, IVA, TUDC, TMANOD As Double
    IMPO = 0
    TUDC = 0
    IVA = 0
    TMANOD = 0
    TOT1 = 0
    UTIMP = 0
  '  DB_PREV.Refresh
    While Not DB_PREV.Recordset.EOF
        If Not IsNull(DB_PREV.Recordset("IMPORTO")) Then
            IMPO = IMPO + DB_PREV.Recordset("IMPORTO")
          End If
        
          If Not IsNull(DB_PREV.Recordset("TOT_UDC")) Then
             TUDC = TUDC + DB_PREV.Recordset("TOT_UDC")
         End If
      
        If Not IsNull(DB_PREV.Recordset("TMANOD")) Then
             TMANOD = TMANOD + DB_PREV.Recordset("TMANOD")
         End If
        DB_PREV.Recordset.MoveNext
        On Error GoTo errore
     Wend
    
    IVA = IMPO * DB_STOPRE.Recordset("IVA") / 100
    TOT1 = TUDC + TMANOD
    UTIMP = IMPO - TOT1
    tipo_finmsg = 0
    
    tot.Caption = Format(IMPO, F_MENU.FormatoEuro)
    IVA1.Caption = Format(IVA, F_MENU.FormatoEuro)
    impo1.Caption = Format(IMPO + IVA, F_MENU.FormatoEuro)
    TUDC1.Caption = Format(TUDC, F_MENU.FormatoEuro)
    TMANOD1.Caption = Format(TMANOD, F_MENU.FormatoEuro)
    manodudc.Caption = Format(UTIMP + TMANOD, F_MENU.FormatoEuro)
    utilimp.Caption = Format(IMPO - TOT1, F_MENU.FormatoEuro)
    
    
   ' Msg = "IL TOTALE DEI CALCOLI DI PREVENTIVO é " & Chr$(13)
   ' Msg = Msg & Chr$(13)
   ' Msg = Msg & "IMPONIBILE : " & Chr$(32) & Format(IMPO, F_MENU.FormatoEuro) & Chr$(13)
   ' Msg = Msg & "IVA        : " & Format(IVA, F_MENU.FormatoEuro) & Chr$(13)
   ' Msg = Msg & "TOTALE     : " & Format(IMPO + IVA, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)
    
    
   ' Msg = Msg & "TOTALE U.D.C.   : " & Format(TUDC, F_MENU.FormatoEuro) & Chr$(13)
   ' Msg = Msg & "TOT. MANOD      : " & Format(TMANOD, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)
    
   ' Msg = Msg & "MANOD + UDC     : " & Format(TUDC + TMANOD, F_MENU.FormatoEuro) & Chr$(13)
   ' Msg = Msg & "UTILE IMP.      : " & Format(IMPO - TOT1, F_MENU.FormatoEuro) & Chr$(13) & Chr$(13)
    
   ' If MsgBox(Msg, tipo_finmsg, "CALCOLI PREVENTIVO") = 1 Then
    'End If
'    DB_PREV.Refresh
'    DB_PREV.Recordset.MoveLast

        
   '     End If
     ' salva = False
      
     ' Call riordino
   '  Me.Timer1.Enabled = True
Exit Sub
errore:
   MsgBox "è inrtervenuto un erroe !", vbExclamation
   On Error Resume Next
  
End Sub

Private Sub BT_sta_Click()
Dim I As Byte
    DB_STAMPANTI.DatabaseName = CurDir & "\SEA.mdb"
    DB_STAMPANTI.RecordSource = "db_stampanti"
    DB_STAMPANTI.Refresh
    I = DB_STAMPANTI.Recordset("IMPOSTATA")
    attualmente.Text = Printers(I).DeviceName
    For I = 0 To Printers.Count - 1
        Stamp.AddItem Printers(I).DeviceName, I
    Next I
    st.ZOrder 0
    Contratto.Value = 0
    st.Visible = True
    Call riordino
    'Call Calcoli
End Sub

Private Sub BT_var_Click()
    Variazione.ZOrder 0
    Variazione.Visible = True
    var.Text = ""
    var.SetFocus
    Call riordino
    'Call Calcoli
End Sub

Private Sub Casa_LostFocus()
Dim esegui As Boolean
    Casa.Text = UCase(Casa.Text)
    esegui = True
    If Codice.Text <> "" And flag Then
        DB_ARTASS.RecordSource = "select * from db_artass where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
        DB_ARTASS.Refresh
        If Not DB_ARTASS.Recordset.EOF Then
            Casa = DB_ARTASS.Recordset("CASA")
            Codice = DB_ARTASS.Recordset("CODICE")
            Des = DB_ARTASS.Recordset("DESCRIZIONE")
            Um = DB_ARTASS.Recordset("UM")
            UDC = DB_ARTASS.Recordset("UDC")
            MANOD = DB_ARTASS.Recordset("Manod")
            Costo = DB_ARTASS.Recordset("COSTO")
            Ricarico = DB_ARTASS.Recordset("RICARICO")
            Prunit = DB_ARTASS.Recordset("LISTINO")
            Prscont = DB_ARTASS.Recordset("LISTINO")
            IVA = DB_ARTASS.Recordset("IVA")
            L9.Visible = True
            L10.Visible = True
            Costo.Visible = True
            Ricarico.Visible = True
            Qty.Text = 1
            Sconto.Text = 0
            esegui = False
        Else
            Call CANCELLA
        End If
        If esegui Then
        DB_ARTICOLI.RecordSource = "select * from db_articoli where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
        DB_ARTICOLI.Refresh
        If Not DB_ARTICOLI.Recordset.EOF Then
            Casa = DB_ARTICOLI.Recordset("CASA")
            Codice = DB_ARTICOLI.Recordset("CODICE")
            Des = DB_ARTICOLI.Recordset("DESCRIZIONE")
            Um = DB_ARTICOLI.Recordset("UM")
            Costo = DB_ARTICOLI.Recordset("COSTO")
            UDC = DB_ARTICOLI.Recordset("costo")
            Ricarico = DB_ARTICOLI.Recordset("RICARICO")
            Prunit = DB_ARTICOLI.Recordset("LISTINO")
            Prscont = DB_ARTICOLI.Recordset("LISTINO")
            IVA = DB_ARTICOLI.Recordset("IVA")
            L9.Visible = True
            L10.Visible = True
            Costo.Visible = True
            Ricarico.Visible = True
            Qty.Text = 1
            Sconto.Text = 0
            esegui = False
        Else
            Call CANCELLA
        End If
        End If
    End If
End Sub

Private Sub codice_LostFocus()
Dim esegui As Boolean
    Codice.Text = UCase(Codice.Text)
    esegui = True
    If Casa.Text <> "" And flag Then
        DB_ARTASS.RecordSource = "select * from db_artass where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
        DB_ARTASS.Refresh
        If Not DB_ARTASS.Recordset.EOF Then
            Casa = DB_ARTASS.Recordset("CASA")
            Codice = DB_ARTASS.Recordset("CODICE")
            Des = DB_ARTASS.Recordset("DESCRIZIONE")
            Um = DB_ARTASS.Recordset("UM")
            UDC = DB_ARTASS.Recordset("UDC")
            MANOD = DB_ARTASS.Recordset("Manod")
            Costo = DB_ARTASS.Recordset("COSTO")
            Ricarico = DB_ARTASS.Recordset("RICARICO")
            Prunit = DB_ARTASS.Recordset("LISTINO")
            Prscont = DB_ARTASS.Recordset("LISTINO")
            IVA = DB_ARTASS.Recordset("IVA")
            L9.Visible = True
            L10.Visible = True
            Costo.Visible = True
            Ricarico.Visible = True
            Qty.Text = 1
            Sconto.Text = 0
            esegui = False
        Else
            Call CANCELLA
        End If
        If esegui Then
        DB_ARTICOLI.RecordSource = "select * from db_articoli where casa = " & Chr$(34) & Casa.Text & Chr$(34) & " and codice= " & Chr$(34) & Codice.Text & Chr$(34)
        DB_ARTICOLI.Refresh
        If Not DB_ARTICOLI.Recordset.EOF Then
            Casa = DB_ARTICOLI.Recordset("CASA")
            Codice = DB_ARTICOLI.Recordset("CODICE")
            Des = DB_ARTICOLI.Recordset("DESCRIZIONE")
            Um = DB_ARTICOLI.Recordset("UM")
            UDC = DB_ARTICOLI.Recordset("COSTO")
            Costo = DB_ARTICOLI.Recordset("COSTO")
            Ricarico = DB_ARTICOLI.Recordset("RICARICO")
            Prunit = DB_ARTICOLI.Recordset("LISTINO")
            Prscont = DB_ARTICOLI.Recordset("LISTINO")
            IVA = DB_ARTICOLI.Recordset("IVA")
      
            L9.Visible = True
            L10.Visible = True
            Costo.Visible = True
            Ricarico.Visible = True
            Qty.Text = 1
            Sconto.Text = 0
            esegui = False
        Else
             Call CANCELLA
        End If
        End If
    End If
End Sub

Private Sub Command1_Click()
    With F_ARTRMO
        .L_DocP.Visible = True
        .mnuart.Enabled = False
        .mnumenu.Enabled = False
        .BT_REGMOD.Visible = False
        .BT_CANCELLA.Visible = False
        .BT_pins.Visible = True
        .BT_pann.Visible = True
    End With
    scelta.Visible = False
    F_ARTRMO.Caption = "Inserimento Articoli Singoli in Preventivo"
    F_PREINS.Hide
    F_ARTRMO.Show
End Sub

Private Sub Command2_Click()
    With F_ASSRMO
        .L_DocP.Visible = True
        .mnuart.Enabled = False
        .mnumenu.Enabled = False
        .BT_REGMOD.Visible = False
        .BT_CANCELLA.Visible = False
        .BT_pins.Visible = True
        .BT_pann.Visible = True
    End With
    scelta.Visible = False
    F_ARTRMO.Caption = "Inserimento Articoli Assemblati in Preventivo"
    F_PREINS.Hide
    F_ASSRMO.Show
End Sub

Private Sub Command3_Click()
    scelta.Visible = False
End Sub
Private Sub Command6_Click()
    Stamp.Clear
    st.Visible = False
End Sub

Private Sub dis_modello()
    ' verticali
'   Printer.Line (42, 8.5)-(95, 8.5)
    Printer.Line (42, 16.5)-(95, 16.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 14.5)-(42, 14.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 20.5)-(95, 20.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 22.5)-(95, 22.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 52.5)-(84.5, 52.5) ', RGB(184, 227, 254), BF
    Printer.Line (12, 54.5)-(62, 54.5) ', RGB(184, 227, 254), BF
    Printer.Line (8, 56)-(62, 56) ', RGB(184, 227, 254), BF
    Printer.Line (8, 57.5)-(62, 57.5) ', RGB(184, 227, 254), BF
    Printer.Line (84.5, 54.5)-(95, 54.5) ', RGB(184, 227, 254), BF
    Printer.Line (84.5, 56.5)-(95, 56.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 58)-(95, 58) ', RGB(184, 227, 254), BF
    Printer.Line (5, 60)-(18, 60) ', RGB(184, 227, 254), BF
    ' orizzontali
    Printer.Line (42, 14.5)-(42, 20.5) ', RGB(184, 227, 254), BF
    Printer.Line (5, 14.5)-(5, 60) ', RGB(184, 227, 254), BF
    Printer.Line (18, 58)-(18, 60) ', RGB(184, 227, 254), BF
   ' Printer.Line (5, 12)-(5, 62)', RGB(184, 227, 254), BF
    Printer.Line (20, 20.5)-(20, 22.5) ', RGB(184, 227, 254), BF
    Printer.Line (58, 20.5)-(58, 52.5) ', RGB(184, 227, 254), BF
   ' Printer.Line (59.5, 12)-(59.5, 62)
    Printer.Line (62, 20.5)-(62, 52.5) ', RGB(184, 227, 254), BF
    Printer.Line (70, 20.5)-(70, 52.5) ', RGB(184, 227, 254), BF
    Printer.Line (65, 52.5)-(65, 58) ', RGB(184, 227, 254), BF
    Printer.Line (84.5, 20.5)-(84.5, 58) ', RGB(184, 227, 254), BF
    Printer.Line (95, 16.5)-(95, 58) ', RGB(184, 227, 254), BF
End Sub
Private Sub Command7_Click()
Dim fine, OK As Boolean
Dim impor As Double
Dim d1 As String, d2 As String, D3 As String, D4 As String, D5 As String, D6 As String, D7 As String, D8 As String, D11 As String, D21 As String, D31 As String
Dim i1 As String, I2 As String
Dim descrizione As String
Dim indi As String
Dim nota As String
Dim CDA As String
Dim codart As String
Dim Cas As String
Dim Prez As Double
Dim v_netto As Double
Dim Qta As Long
Dim Linea As Integer
Dim tipo_finmsg As Integer
Dim Msg, UMI As String
Dim Lpt As String
Dim V_IVA As Double
Dim v_totale As Double
Dim aliq As Single
Dim lung_sta As Integer
Dim colonna As Integer
Dim pag As Integer
Dim logo  As New StdPicture
Dim Appl As Object
Dim Doc As Object
  
     If CInt(copiuz.Text) = 0 Then GoTo Nfatt

If Stamp.ListIndex >= 0 Then
    Set Printer = Printers(Stamp.ListIndex)
    DB_STAMPANTI.Recordset.Edit
    DB_STAMPANTI.Recordset("IMPOSTATA") = Stamp.ListIndex
    DB_STAMPANTI.Recordset.Update
End If

If Contratto.Value = vbChecked Then
      Set Appl = CreateObject("Word.Application")
    'background dell'applicazione
      Appl.application.Visible = False
      On Error GoTo errato
      Set Doc = Appl.Documents.Open(App.Path & "\capitolato")
      Doc.FormFields("Data").Result = DATA.Text 'Adesso
      Appl.application.PrintOut
    'chiusura dell'applicazione e Doc
      Doc.CLOSE (False)
      Appl.quit
      Set Doc = Nothing
      Set Appl = Nothing
End If

' Con 12 caratteri per pollice
' [0..95] colonne
' [0..74] righe
'On Error Resume Next
Printer.ScaleMode = 4
'Printer.ScaleHeight = 330
'Printer.ScaleWidth = 217
Printer.PaperSize = 9
Printer.Copies = copiuz.Text
'Printer.ScaleMode = 6
Printer.FontTransparent = True
'Correctly sets the background mix mode to transparent
iBKMode = SetBkMode(Printer.hDC, TRANSPARENT)

If err.Number > 0 Then
    tipo_finmsg = 0
    Msg = "Impossibile eseguire la stampa." & Chr$(13)
    Msg = Msg & "Verificare che la stampante impostata sia quella corretta"
    If MsgBox(Msg, tipo_finmsg, "Stampa Preventivo") = 1 Then
    End If
Else
    If tutte.Value = 1 Then
        pag = 0
    Else
        pag = nump.Text
    End If
    attuale = 1
    fine = False
    DB_CLIENTI.DatabaseName = CurDir & "\SEA.mdb"
    DB_CLIENTI.RecordSource = "select * from db_clienti where codice = " & DB_STOPRE.Recordset("CODCLI")
    DB_CLIENTI.Refresh
    aliq = DB_STOPRE.Recordset("IVA")
    DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
    DB_PREV.Refresh
While Not fine
    F_PREINS.Caption = "STAMPA DEL PREVENTIVO IN CORSO SI PREGA DI ATTENDERE"
    
' parte dedicata alla stampa del modello su foglio A4

If modulo.Value = vbUnchecked Then
  Set logo = LoadPicture(CurDir & "\logoP.bmp")
    Printer.PaintPicture logo, 1, 1, 37, 9
    
    
    Printer.FontName = "Arial"
    Printer.ForeColor = vbBlue 'RGB(184, 227, 254)
    Printer.FontSize = 7.5
    Printer.CurrentX = 55
    Printer.CurrentY = 2
    Lpt = "IMPIANTI ELETTRICI CIVILI INDUSTRIALI"
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 3
    Lpt = "AUDIOVISIVI - SERVICE PER CONCERTI"
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 4
    Lpt = "COMMERCIO MATERIALE ELETTRICO - TV ANTENNE - TELEFONIA"
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 5
    Lpt = "DOMOTICA - AUTOMATISMI - RIVELAZIONE INCENDI "
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 6
    Lpt = "PARTITA IVA/CODICE FISCALE 0170798 034 6"
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 55
    Printer.CurrentY = 7
    Lpt = "C.I.A.A. PR172901  ALBO ARTIGIANI 52134"
    Call Stampa(pag, Lpt)
    Printer.ForeColor = False
    
    dis_modello
    
    Printer.FontName = "Times New Roman"
    Printer.FontBold = True
    Printer.FontSize = 12
    Printer.CurrentX = 7
    Printer.CurrentY = 15
    Lpt = "PREVENTIVO  N."
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 18
    Printer.CurrentY = 17
    Lpt = "DEL :"
    Call Stampa(pag, Lpt)
    
    Printer.FontBold = False
    Printer.FontSize = 7
    Printer.CurrentX = 10
    Printer.CurrentY = 21.1
    Lpt = "CODICE"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 35
    Printer.CurrentY = 21.1
    Lpt = "DESCRIZIONE"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 59
    Printer.CurrentY = 21.1
    Lpt = "U.M."
    Call Stampa(pag, Lpt)
        
    Printer.CurrentX = 64
    Printer.CurrentY = 21.1
    Lpt = "QUANT."
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 72
    Printer.CurrentY = 21.1
    Lpt = "PREZZO UNITARIO"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 87
    Printer.CurrentY = 21.1
    Lpt = "IMPORTO"
    Call Stampa(pag, Lpt)
    
    Printer.FontSize = 9
    Printer.CurrentX = 76
    Printer.CurrentY = 53
    Lpt = "imponibile"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 7
    Printer.CurrentY = 53.5
    Lpt = "NOTE :"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 71
    Printer.CurrentY = 55
    Lpt = "IVA...........%"
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 67
    Printer.CurrentY = 57
    Lpt = "TOTALE  DOCUMENTO"
    Call Stampa(pag, Lpt)
End If
' Fine Parte dedicata alla stampa del modello su foglio A4

        If Not IsNull(DB_CLIENTI.Recordset("NOME")) Then
         indi = DB_CLIENTI.Recordset("NOME")
          Else
            indi = ""
        End If
        i1 = dividi(indi, 39)
        indi = Right(indi, Len(indi) - Len(i1))
        I2 = dividi(indi, 39)
        indi = Right(indi, Len(indi) - Len(I2))
        i1 = Trim(i1)
        I2 = Trim(I2)
        Printer.FontBold = True
        Printer.FontSize = 12
        Printer.CurrentX = 52
        Printer.CurrentY = 10
        Call Stampa(pag, i1)
        If I2 <> "" Then
            Printer.CurrentX = 54
            Printer.CurrentY = 11
            Call Stampa(pag, I2)
        End If
  
    Printer.FontBold = False
    Printer.FontSize = 11
    Printer.CurrentX = 52
    Printer.CurrentY = 12
    Lpt = DB_CLIENTI.Recordset("VIA")
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 52
    Printer.CurrentY = 13
    Lpt = DB_CLIENTI.Recordset("CAP") & ", " & DB_CLIENTI.Recordset("CITTA") & " " & DB_CLIENTI.Recordset("PROVINCIA")
    Call Stampa(pag, Lpt)
  
  '  Printer.FontBold = True
    Printer.CurrentX = 52
    Printer.CurrentY = 17
    Lpt = "P.IVA/Cod.Fisc.: " & DB_CLIENTI.Recordset("PIVA") & " "
    Call Stampa(pag, Lpt)
    
    Printer.CurrentX = 52
    Printer.CurrentY = 18
    Lpt = "Telefono: " & DB_CLIENTI.Recordset("TEL") & "  - Codice Cliente : " & DB_STOPRE.Recordset("codcli")
    Call Stampa(pag, Lpt)
      
    Printer.FontBold = True
    Printer.FontSize = 13
    Printer.CurrentX = 28
    Printer.CurrentY = 15
    Lpt = NORD.Text
    Call Stampa(pag, Lpt)
    Printer.CurrentX = 28
    Printer.CurrentY = 17
    Lpt = DATA.Text
    Call Stampa(pag, Lpt)
    Linea = 23
   ' Printer.FontName = "Times New Roman"
    Printer.FontName = "Courier New"
    Printer.FontSize = 10
    Printer.FontBold = False
    
          If Not IsNull(DB_STOPRE.Recordset("NOTE")) Then
            nota = DB_STOPRE.Recordset("NOTE")
        Else
            nota = ""
        End If
        d1 = dividi(nota, 50)
        nota = Right(nota, Len(nota) - Len(d1))
        d2 = dividi(nota, 55)
        nota = Right(nota, Len(nota) - Len(d2))
        D3 = dividi(nota, 55)
        d1 = Trim(d1)
        d2 = Trim(d2)
        D3 = Trim(D3)
        Printer.CurrentX = 15
        Printer.CurrentY = 53
        Call Stampa(pag, d1)
        If d2 <> "" Then
            Printer.CurrentX = 10
            Printer.CurrentY = 55
            Call Stampa(pag, d2)
            If D3 <> "" Then
                Printer.CurrentX = 10
                Printer.CurrentY = 56.5
                Call Stampa(pag, D3)
            End If
        End If
    
    While Not DB_PREV.Recordset.EOF And Not Linea > 51
        codart = ""
        Casa = ""
        CDA = ""
        D11 = ""
        D21 = ""
        D31 = ""
        If Not IsNull(DB_PREV.Recordset("CASA")) Then
            Cas = DB_PREV.Recordset("CASA")
        End If
        
        If Not IsNull(DB_PREV.Recordset("CODICE")) Then
            codart = DB_PREV.Recordset("CODICE")
            CDA = Cas & " " & codart
        End If
        D11 = Mid(CDA, 1, 13)
        Printer.CurrentX = 7
        Printer.CurrentY = Linea
        Call Stampa(pag, D11)
        If Len(CDA) > 13 Then
            D21 = Mid(CDA, 14, 13)
            If Len(D21) > 13 Then
                D31 = Mid(CDA, 26, 13)
            End If
        End If
        If Not IsNull(DB_PREV.Recordset("DESCRIZIONE")) Then
            descrizione = DB_PREV.Recordset("DESCRIZIONE")
        Else
            descrizione = ""
        End If
        d1 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(d1))
        d2 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(d2))
        D3 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D3))
        D4 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D4))
        D5 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D5))
        D6 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D6))
        D7 = dividi(descrizione, 36)
        descrizione = Right(descrizione, Len(descrizione) - Len(D7))
        D8 = dividi(descrizione, 36)
        d1 = Trim(d1)
        d2 = Trim(d2)
        D3 = Trim(D3)
        D4 = Trim(D4)
        D5 = Trim(D5)
        D6 = Trim(D6)
        D7 = Trim(D7)
        D8 = Trim(D8)
        
        Printer.CurrentX = 20
        Printer.CurrentY = Linea
        Call Stampa(pag, d1)
        
        If Not IsNull(DB_PREV.Recordset("UM")) Then
            UMIS = DB_PREV.Recordset("UM")
            Printer.CurrentX = 59
            Printer.CurrentY = Linea
            Call Stampa(pag, Um)
        End If
        
        If Not IsNull(DB_PREV.Recordset("QUANTITA")) Then
            Qta = DB_PREV.Recordset("QUANTITA")
            If Qta - Int(Qta) = 0 Then
                lung_sta = Len(Format(Qta, F_MENU.FormatoEuro))
                Printer.CurrentX = 68 - lung_sta
                Printer.CurrentY = Linea
                Call Stampa(pag, (Format(Qty, F_MENU.FormatoEuro)))
            Else
                lung_sta = Len(Format(Qty, F_MENU.FormatoEuro))
                Printer.CurrentX = 68 - lung_sta
                Printer.CurrentY = Linea
                Call Stampa(pag, Format(Qty, F_MENU.FormatoEuro))
            End If
        End If
        
        If Not IsNull(DB_PREV.Recordset("PREZZO")) Then
            Prez = DB_PREV.Recordset("PREZZO")
            lung_sta = Len(Format(Prez, F_MENU.FormatoEuro))
            colonna = 81 - lung_sta
            Printer.CurrentX = colonna
            Printer.CurrentY = Linea
            Call Stampa(pag, Format(Prez, F_MENU.FormatoEuro))
        End If
        
        If Not IsNull(DB_PREV.Recordset("IMPORTO")) Then
            impor = DB_PREV.Recordset("IMPORTO")
            lung_sta = Len(Format(impor, F_MENU.FormatoEuro))
            colonna = 94 - lung_sta
            Printer.CurrentX = colonna
            Printer.CurrentY = Linea
            Call Stampa(pag, Format(impor, F_MENU.FormatoEuro))
        End If
        
        If d2 <> "" Or D21 <> "" Then
            Linea = Linea + 1
            If d2 <> "" Then
                Printer.CurrentX = 20
                Printer.CurrentY = Linea
                Call Stampa(pag, d2)
            End If
            If D21 <> "" Then
                Printer.CurrentX = 7
                Printer.CurrentY = Linea
                Call Stampa(pag, D21)
            End If
            If D3 <> "" Or D31 <> "" Then
                Linea = Linea + 1
                If D3 <> "" Then
                    Printer.CurrentX = 20
                    Printer.CurrentY = Linea
                    Call Stampa(pag, D3)
                End If
                If D31 <> "" Then
                    Printer.CurrentX = 7
                    Printer.CurrentY = Linea
                    Call Stampa(pag, D31)
                End If
                If D4 <> "" Then
                    Linea = Linea + 1
                    Printer.CurrentX = 20
                    Printer.CurrentY = Linea
                    Call Stampa(pag, D4)
                    If D5 <> "" Then
                        Linea = Linea + 1
                        Printer.CurrentX = 20
                        Printer.CurrentY = Linea
                        Call Stampa(pag, D5)
                        If D6 <> "" Then
                            Linea = Linea + 1
                            Printer.CurrentX = 20
                            Printer.CurrentY = Linea
                            Call Stampa(pag, D6)
                            If D7 <> "" Then
                                Linea = Linea + 1
                                Printer.CurrentX = 20
                                Printer.CurrentY = Linea
                                Call Stampa(pag, D7)
                                If D8 <> "" Then
                                    Linea = Linea + 1
                                    Printer.CurrentX = 20
                                    Printer.CurrentY = Linea
                                    Call Stampa(pag, D8)
                                End If
                            End If
                       End If
                    End If
                End If
            End If
        End If
        Linea = Linea + 1
        DB_PREV.Recordset.MoveNext
    Wend
    If DB_PREV.Recordset.EOF Then
        fine = True
        Printer.CurrentX = 75
        Printer.CurrentY = 55
        Lpt = CStr(aliq)
        Call Stampa(pag, Lpt)
          
    ' Da cambiare quando la valuta sarà in EURO
        Netto (aliq)
      '  S_IVA (aliq)
        v_netto = t_netto
        
        lung_sta = Len(Format(v_netto, F_MENU.FormatoEuro))
        colonna = 94 - lung_sta
        Printer.CurrentX = colonna
        Printer.CurrentY = 53
        Call Stampa(pag, Format(v_netto, F_MENU.FormatoEuro))
        
        V_IVA = T_IVA
        lung_sta = Len(Format(V_IVA, F_MENU.FormatoEuro))
        colonna = 94 - lung_sta
        Printer.CurrentX = colonna
        Printer.CurrentY = 55
        Call Stampa(pag, Format(V_IVA, F_MENU.FormatoEuro))
        
        v_totale = v_netto + V_IVA
        lung_sta = Len(Format(v_totale, F_MENU.FormatoEuro))
        colonna = 94 - lung_sta
        Printer.CurrentX = colonna
        Printer.CurrentY = 57
        Call Stampa(pag, Format(v_totale, F_MENU.FormatoEuro))
              
        Printer.CurrentX = 7
        Printer.CurrentY = 59
        Lpt = "Pagina " & attuale
        Call Stampa(pag, Lpt)
        
        Printer.EndDoc
    Else
        Printer.CurrentX = 7
        Printer.CurrentY = 59
        Lpt = "Pagina " & attuale
        Call Stampa(pag, Lpt)
        
        Printer.CurrentX = 89
        Printer.CurrentY = 57
        Call Stampa(pag, "Segue")
        If pag = 0 Then
            Printer.NewPage
            attuale = attuale + 1
        Else
            attuale = attuale + 1
        End If
    End If
Wend

F_PREINS.Caption = "Creazione Preventivi"
End If
On Error GoTo 0
st.Visible = False
Call riordino
'Call Calcoli
copiuz.Text = 0
Stamp.Clear
Exit Sub
Nfatt: MsgBox "Devi dirmi Quante Copie Ne Vuoi!!!!", vbExclamation
Exit Sub
errato: MsgBox "il documento citato non e presente oppure presenta un nome errato  il nome corretto è 'Capitolato' ", vbExclamation
Resume Next
Resume
End Sub


Private Sub Command8_Click()
    Variazione.Visible = False
End Sub

Private Sub Command9_Click()
Dim Ric As Single
    Variazione.Visible = False
    If var.Text <> "" Then
        DB_PREV.Refresh
        salva = True
        While Not DB_PREV.Recordset.EOF
            If Not IsNull(DB_PREV.Recordset("PREZZO")) Then
                Ric = DB_PREV.Recordset("PREZZO") * var.Text / 100
                DB_PREV.Recordset.Edit
                DB_PREV.Recordset("PREZZO") = Format((DB_PREV.Recordset("PREZZOI") - Ric), F_MENU.FormatoEuro)
      '        On Error Resume Next
                DB_PREV.Recordset("IMPORTO") = Format((DB_PREV.Recordset("PREZZO") * DB_PREV.Recordset("QUANTITA")), F_MENU.FormatoEuro)
                DB_PREV.Recordset("SCONTO") = Format(var.Text, F_MENU.FormatoEuro)
                DB_PREV.Recordset.Update
            End If
            DB_PREV.Recordset.MoveNext
        Wend
        salva = False
        Me.Timer1.Enabled = True
        
    End If
End Sub

Private Sub DB_prev_Validate(Action As Integer, Save As Integer)
If salva = False Then Save = False
End Sub

Private Sub Netto(V_IVA As Double)
    DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
    DB_PREV.Refresh
    t_netto = "0"
    T_IVA = "0"
    While Not DB_PREV.Recordset.EOF
        If Not IsNull(DB_PREV.Recordset("PREZZO")) Then
            t_netto = t_netto + DB_PREV.Recordset("IMPORTO")
        End If
    DB_PREV.Recordset.MoveNext
    Wend
    T_IVA = t_netto * V_IVA / 100
End Sub
'Private Sub S_IVA(V_IVA As Currency)
'    DB_PREV.RecordSource = "select * from db_prev where NUMERO =" & NORD.Text & " order by ID "
'    DB_PREV.Refresh
'       T_IVA = "0"
'        T_IVA = t_netto * V_IVA / 100
'End Sub

Private Sub DBGrid1_KeyPress(KeyAscii As Integer)
    If Chr(KeyAscii) = "g" Or Chr(KeyAscii) = "G" Then DBGrid1.Height = 8500
    If Chr(KeyAscii) = "p" Or Chr(KeyAscii) = "P" Then DBGrid1.Height = 2616
End Sub

Private Sub Form_Activate()
    flag = True
   ' Call Calcoli
    If BT_elart.Visible = False Then
       '  Call Calcoli
        DB_PREV.DatabaseName = CurDir$ & "\SEA.mdb"
        DB_PREV.RecordSource = "select * from db_Prev where numero = " & NORD.Text & " order by ID"
        DB_PREV.Refresh
        Call Calcoli
        flag = False
    
    End If
    DB_ARTICOLI.DatabaseName = CurDir$ & "\SEA.mdb"
    DB_ARTASS.DatabaseName = CurDir$ & "\SEA.mdb"
    DB_STOPRE.DatabaseName = CurDir$ & "\SEA.mdb"
    DB_STOPRE.RecordSource = "select * from db_stopre where numero = " & NORD.Text
    DB_STOPRE.Refresh
    DB_EURO.DatabaseName = CurDir & "\SEA.mdb"
    DB_EURO.RecordSource = "db_EURO"
    DB_EURO.Refresh

' If L_DocP.Visible Then
'   Call riordino
  '  Else
'    Call Calcoli
    Call riordino
  ' End If
    
    
'   salva = False

    
   ' DBGrid1.Columns(0).Visible = False
    'DBGrid1.Columns(1).Visible = False
    'DBGrid1.Columns(2).Width = 620
   ' DBGrid1.Columns(2).Alignment = 2
   ' DBGrid1.Columns(3).Width = 620
   ' DBGrid1.Columns(3).Alignment = 2
   ' DBGrid1.Columns(4).Width = 920
   ' DBGrid1.Columns(4).Alignment = 2
   ' DBGrid1.Columns(5).Width = 4700
   ' DBGrid1.Columns(6).Width = 500
   ' DBGrid1.Columns(6).Alignment = 2
   ' DBGrid1.Columns(7).Width = 723
   ' DBGrid1.Columns(7).Alignment = 2
   ' DBGrid1.Columns(8).Width = 680
   ' DBGrid1.Columns(9).Width = 680
   ' DBGrid1.Columns(10).Width = 680
   ' DBGrid1.Columns(11).Width = 680
   ' DBGrid1.Columns(12).Width = 680
   ' DBGrid1.Columns(13).Width = 680
   ' DBGrid1.Columns(14).Width = 550
   ' DBGrid1.Columns(15).Width = 550
   ' DBGrid1.Columns(16).Width = 680
End Sub

Private Sub Form_Deactivate()
Dim IMPO, IVA, parz As Double
    IMPO = 0
    DB_PREV.Refresh
    While Not DB_PREV.Recordset.EOF
        If Not IsNull(DB_PREV.Recordset("PREZZO")) And Not IsNull(DB_PREV.Recordset("QUANTITA")) And Not IsNull(DB_PREV.Recordset("IVA")) Then
            IMPO = IMPO + DB_PREV.Recordset("IMPORTO")
        End If
        DB_PREV.Recordset.MoveNext
    Wend
    DB_STOPRE.Recordset.Edit
    DB_STOPRE.Recordset("IMPONIBILE") = Format(IMPO, F_MENU.FormatoEuro)
    DB_STOPRE.Recordset.Update
  
End Sub


Private Sub Form_Load()
Dim X As Integer
Dim Y As Integer
    X = (Screen.Width - 11400) / 2
    Y = (Screen.Height - 8004) / 2
    F_PREINS.Move X, Y
End Sub

Private Sub Form_Resize()
DBGrid1.Width = Me.Width - 250

End Sub
Private Sub Form_Unload(Cancel As Integer)
    Call Form_Deactivate
    End
End Sub

Private Sub IVA_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If IVA.Text <> "" And Not IsNumeric(IVA.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        IVA.SetFocus
    End If
End Sub

Private Sub MANOD_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If MANOD.Text <> "" And Not IsNumeric(MANOD.Text) Then
        tipo_finmsg = 0
        Msg = "Il prezzo non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        MANOD.SetFocus
    End If
   End Sub
  
Private Sub mnuesci_Click()
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_newvoce.Visible = True
    BT_elart.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_insvoce.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    F_PREINS.Hide
    F_MENU.Show
End Sub

Private Sub mnuins_Click()
    F_MENU.DATA.Text = Date
    F_MENU.DB_STOPRE.DatabaseName = CurDir & "\SEA.mdb"
    F_MENU.DB_STOPRE.RecordSource = "select * from db_stopre order by numero"
    F_MENU.DB_STOPRE.Refresh
    If Not F_MENU.DB_STOPRE.Recordset.EOF Then
        F_MENU.DB_STOPRE.Recordset.MoveLast
        F_MENU.NORD.Text = DB_STOPRE.Recordset("numero") + 1
    Else
        F_MENU.NORD.Text = 1
    End If
    F_MENU.Prev.Visible = True
    F_MENU.NORD.Visible = True
    F_MENU.dat.Visible = True
    F_MENU.DATA.Visible = True
    F_MENU.num.Visible = True
    F_MENU.V_IVA.Visible = True
    F_MENU.IVA.Visible = True
    F_MENU.BtIns.Visible = True
    F_MENU.Btann.Visible = True
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_newvoce.Visible = True
    BT_elart.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_insvoce.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    F_PREINS.Hide
    F_MENU.Show
End Sub

Private Sub mnuric_Click()
    Bt_addnota.Visible = True
    BT_parz.Visible = True
    BT_newvoce.Visible = True
    BT_elart.Visible = False
    L9.Visible = False
    L10.Visible = False
    Costo.Visible = False
    Ricarico.Visible = False
    BT_modvoce.Visible = True
    BT_cancvoce.Visible = True
    BT_insvoce.Visible = False
    BT_annvoce.Visible = False
    BT_forn.Visible = True
    F_PREINS.Hide
    F_STOPRE.Show
End Sub

Private Sub nump_Change()
     If nump.Text <> "" Then tutte.Value = 0
End Sub

Private Sub nump_GotFocus()
    If nump.Text <> "" Then tutte.Value = 0
End Sub

Private Sub Prscont_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Prscont.Text <> "" And Not IsNumeric(Prscont.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        Prscont.SetFocus
    End If
End Sub

Private Sub Prunit_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Prunit.Text <> "" And Not IsNumeric(Prunit.Text) Then
        tipo_finmsg = 0
        Msg = "Il prezzo non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        Prunit.SetFocus
    End If
    If Prunit.Text <> "" And IsNumeric(Prunit.Text) Then
        Sconto.Text = 0
        Prscont.Text = Prunit.Text
        IVA.Text = DB_STOPRE.Recordset("IVA")
    End If
End Sub


Private Sub Qty_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Qty.Text <> "" And Not IsNumeric(Qty.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        Qty.SetFocus
    End If
End Sub


Private Sub r_Click()
F_PREINS.Hide
F_STOPRE.Show
F_STOPRE.Codice_Cliente.Visible = True
'Call F_STOPRE.ordCli_Click

'DB_STOPRE.RecordSource = "select * from db_stopre where codcli=" & F_STOPRE.cliente.Text
'         DB_STOPRE.Refresh
'            If DB_STOPRE.Recordset.EOF Then
               ' Call messaggio
'           End If
'Call riord

End Sub

Private Sub Sconto_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
Dim sc As Currency
    If Sconto.Text <> "" And Not IsNumeric(Sconto.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        Sconto.SetFocus
    Else
    If Sconto.Text <> "" And Prunit <> "" Then
        sc = Prunit.Text * Sconto.Text / 100
        Prscont = Prunit - sc
    End If
    End If
End Sub

Private Sub Timer1_Timer()
Form_Activate
'Call Calcoli
Me.Timer1.Enabled = False
End Sub

Private Sub tutte_Click()
    If tutte.Value = 1 Then
        nump.Text = ""
    End If
End Sub

Private Sub UM_LostFocus()
    Um.Text = UCase(Um.Text)
End Sub

Private Sub Var_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If var.Text <> "" And Not IsNumeric(var.Text) Then
        tipo_finmsg = 0
        Msg = "La Quantità non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Creazione Preventivo") = 1 Then
        End If
        var.SetFocus
    End If
End Sub 





questo e il codice dove prelevo l'articolo


Option Compare Text
Dim flag, flag1 As Boolean
Dim pos_db, cont, pos_ric As Integer
Dim salva As Boolean

Private Sub BT_CANCELLA_Click()
Dim Msg As String
Dim tipo_finmsg As Integer
    If Not DB_ARTICOLI.Recordset.EOF Then
        tipo_finmsg = 4
        Msg = "Conferma la Cancellazione dei dati di" & Chr$(13)
        Msg = Msg & DB_ARTICOLI.Recordset("CASA") & " " & DB_ARTICOLI.Recordset("CODICE") & " ?"
        If MsgBox(Msg, tipo_finmsg, "Cancella Dati Articolo") = 6 Then
            salva = True
            DB_ARTICOLI.Recordset.Delete
            salva = False
            DB_ARTICOLI.Recordset.MoveNext
            If DB_ARTICOLI.Recordset.EOF Then
                DB_ARTICOLI.Refresh
                If Not DB_ARTICOLI.Recordset.EOF Then DB_ARTICOLI.Recordset.MoveLast
            End If
            flag = False
            flag1 = False
            ric_casa.Text = ""
            Ric_cod.Text = ""
            ric_des.Text = ""
            flag = True
            flag1 = True
            DB_ART.Refresh
        End If
    End If
End Sub

Private Sub BT_pann_Click()
    BT_pins.Visible = False
    BT_pann.Visible = False
    BT_REGMOD.Visible = True
    BT_CANCELLA.Visible = True
    mnuart.Enabled = True
    mnumenu.Enabled = True
    F_ARTRMO.Caption = "Ricerca e Modifica dati Articoli Singoli"
    If L_DocP.Visible Then
        F_ARTRMO.Hide
        F_PREINS.Show
    End If
    If L_DocB.Visible Then
        F_ARTRMO.Hide
        F_BOLINS.Show
    End If
    If L_DocF.Visible Then
        F_ARTRMO.Hide
        F_FATINS.Show
    End If
    If L_DocR.Visible Then
        F_ARTRMO.Hide
        F_RICINS.Show
    End If
    L_DocF.Visible = False
    L_DocP.Visible = False
    L_DocB.Visible = False
    L_DocR.Visible = False
End Sub

Private Sub BT_pins_Click()
If Not DB_ARTICOLI.Recordset.EOF Then
    BT_pins.Visible = False
    BT_pann.Visible = False
    BT_REGMOD.Visible = True
    BT_CANCELLA.Visible = True
    mnuart.Enabled = True
    mnumenu.Enabled = True
    F_ARTRMO.Caption = "Ricerca e Modifica dati Articoli Singoli"
    If L_cantieri.Visible Then
    With F_CANTINS
        .DB_CANT.DatabaseName = CurDir & "\SEA.mdb"
        .DB_CANT.RecordSource = "select * from db_cant where CANT = " & .NORD.Text & " and com = " & .com.Text
        .DB_CANT.Refresh
        If Not .DB_CANT.Recordset.EOF Then
            .DB_CANT.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .C0.Visible = True
        .R0.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_CANTINS.Show
    End If
    If L_DocP.Visible Then
    With F_PREINS
        .DB_PREV.DatabaseName = CurDir & "\SEA.mdb"
        .DB_PREV.RecordSource = "select * from db_Prev where numero =" & .NORD.Text '& " order by ID"
        .DB_PREV.Refresh
        If Not .DB_PREV.Recordset.EOF Then
            .DB_PREV.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_PREINS.Show
    End If
    If L_DocF.Visible Then
    With F_FATINS
        .DB_FATTURE.DatabaseName = CurDir & "\SEA.mdb"
        .DB_FATTURE.RecordSource = "select * from db_fatture where numero = " & .NORD.Text '& "order By ID"
        .DB_FATTURE.Refresh
        If Not .DB_FATTURE.Recordset.EOF Then
            .DB_FATTURE.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_FATINS.Show
    End If
    If L_DocFele.Visible Then
    With F_FATTELE
        .DB_FATTELE.DatabaseName = CurDir & "\SEA.mdb"
        .DB_FATTELE.RecordSource = "select * from db_fattele where numero = " & .NORD.Text '& "order By ID"
        .DB_FATTELE.Refresh
        If Not .DB_FATTELE.Recordset.EOF Then
            .DB_FATTELE.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_FATTELE.Show
    End If
    If L_DocB.Visible Then
    With F_BOLINS
        .DB_BOLLE.DatabaseName = CurDir & "\SEA.mdb"
        .DB_BOLLE.RecordSource = "select * from db_BOLLE where numero = " & .NORD.Text '& "order by ID"
        .DB_BOLLE.Refresh
        If Not .DB_BOLLE.Recordset.EOF Then
            .DB_BOLLE.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_BOLINS.Show
    End If
If L_DocR.Visible Then
    With F_RICINS
        .DB_RICEVUTE.DatabaseName = CurDir & "\SEA.mdb"
        .DB_RICEVUTE.RecordSource = "select * from db_ricevute where numero = " & .NORD.Text
        .DB_RICEVUTE.Refresh
        If Not .DB_RICEVUTE.Recordset.EOF Then
            .DB_RICEVUTE.Recordset.MoveLast
        End If
        .Casa = Casa.Text
        .Codice = Codice.Text
        .Des = Des.Text
        .Um = Um.Text
        .Costo = Prezzo.Text
        .Ricarico = Ricarico.Text
        .Prunit = DB_ARTICOLI.Recordset("LISTINO")
        .Prscont = DB_ARTICOLI.Recordset("LISTINO")
        .IVA = IVA.Text
        .L9.Visible = True
        .L10.Visible = True
        .Costo.Visible = True
        .Ricarico.Visible = True
        .Qty.Text = 1
        .Sconto.Text = 0
    End With
    F_ARTRMO.Hide
    F_RICINS.Show
    End If
    L_DocF.Visible = False
    L_DocP.Visible = False
    L_DocB.Visible = False
    L_DocR.Visible = False
    L_cantieri.Visible = False
End If
End Sub

Private Sub BT_REGMOD_Click()
Dim Msg As String
Dim tipo_finmsg As Integer
Dim esegui As Boolean
Dim pos As Integer
If Not DB_ARTICOLI.Recordset.EOF Then
    esegui = True
    pos = DB_ARTICOLI.Recordset.AbsolutePosition
    DB_ART.Refresh
    While (Not DB_ART.Recordset.EOF) And esegui
        If DB_ART.Recordset("CASA") = Casa.Text And DB_ART.Recordset("CODICE") = Codice.Text And DB_ART.Recordset.AbsolutePosition <> pos Then
            esegui = False
        Else
            DB_ART.Recordset.MoveNext
        End If
    Wend
    If esegui Then
        salva = True
        DB_ARTICOLI.Recordset.Edit
        If Prezzo.Text <> "" And Ricarico.Text <> "" Then
            If DB_ARTICOLI.Recordset("COSTO") <> Prezzo.Text Or DB_ARTICOLI.Recordset("Ricarico") <> Ricarico.Text Or DB_ARTICOLI.Recordset("iva") <> IVA.Text Then
                DB_ARTICOLI.Recordset("data") = Date
            End If
            DB_ARTICOLI.Recordset("LISTINO") = Format((Prezzo.Text + (Prezzo.Text * Ricarico.Text / 100)), F_MENU.FormatoEuro)
            DB_ARTICOLI.Recordset("TOTIVA") = Format(((DB_ARTICOLI.Recordset("LISTINO") * DB_ARTICOLI.Recordset("IVA") / 100)), F_MENU.FormatoEuro)
            DB_ARTICOLI.Recordset("Totale") = Format((DB_ARTICOLI.Recordset("LISTINO") + (DB_ARTICOLI.Recordset("TOTIVA"))), F_MENU.FormatoEuro)
        End If
        DB_ARTICOLI.Recordset.Update
        salva = False
    Else
        tipo_finmsg = 0
        Msg = "Il Codice della casa " & DB_ARTICOLI.Recordset("CASA") & " è già esistente."
        Msg = Msg & " La modifica non può essere registrata"
        If MsgBox(Msg, tipo_finmsg, "Modifica Dati Articoli") = 1 Then
            Casa.SetFocus
        End If
    End If
End If
End Sub

Private Sub BT_RIC_Click()
Dim pos_str, tipo_finmsg As Integer
Dim var_db, Msg As String
Dim trovato As Boolean
If Not DB_ARTICOLI.Recordset.EOF Then
If ric_des.Text <> "" Then
    trovato = False
    pos_db = DB_ARTICOLI.Recordset.AbsolutePosition
    cont = 1
    While cont < 3 And Not trovato
        While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato And cont < 3
            var_db = DB_ARTICOLI.Recordset("DESCRIZIONE")
            pos_str = InStr(var_db, ric_des.Text)
            If pos_str > 0 Then
                trovato = True
            Else
                DB_ARTICOLI.Recordset.MoveNext
                If DB_ARTICOLI.Recordset.AbsolutePosition = pos_db Then
                    cont = 3
                End If
            End If
        Wend
        If DB_ARTICOLI.Recordset.EOF Then
            DB_ARTICOLI.Refresh
            cont = cont + 1
        End If
    Wend
    If Not trovato Then
        tipo_finmsg = 0
        Msg = "ATTENZIONE: La parola non è presente in elenco"
        If MsgBox(Msg, tipo_finmsg, "Ricerca Articolo") = 1 Then
            ric_des.SetFocus
        End If
    Else
        BT_RIC.Visible = False
        succ.Visible = True
        BT_stop.Visible = True
        ric_des.Locked = True
    End If
End If
End If
End Sub

Private Sub BT_STOP_Click()
    BT_stop.Visible = False
    succ.Visible = False
    BT_RIC.Visible = True
    ric_des.Locked = False
End Sub

Private Sub carsca_Click()
    F_ARTRMO.Hide
    F_ARTINV.Show
End Sub

Private Sub Casa_LostFocus()
    Casa.Text = UCase(Casa.Text)
End Sub
Private Sub codice_LostFocus()
    Codice.Text = UCase(Codice.Text)
End Sub
Private Sub DB_ARTICOLI_Validate(Action As Integer, Save As Integer)
If salva = False Then Save = False
End Sub

Private Sub Form_Activate()
Dim sdir As String
    sdir = CurDir
    DB_ARTICOLI.DatabaseName = sdir & "\sea.mdb"
    DB_ARTICOLI.RecordSource = "select * from db_articoli order by casa,codice"
    DB_ARTICOLI.Refresh
    DB_ART.DatabaseName = sdir & "\sea.mdb"
    DB_ART.RecordSource = "select * from db_articoli order by casa,codice"
    DB_ART.Refresh
    
    
    DBGrid1.Columns(0).Width = 500
    DBGrid1.Columns(0).Alignment = 0
    DBGrid1.Columns(1).Width = 920
    DBGrid1.Columns(1).Alignment = 0
    DBGrid1.Columns(2).Width = 3500
    DBGrid1.Columns(2).Alignment = 0
    DBGrid1.Columns(3).Width = 380
    DBGrid1.Columns(3).Alignment = 2
    DBGrid1.Columns(4).Width = 870
    DBGrid1.Columns(4).Alignment = 0
    DBGrid1.Columns(5).Width = 750
    DBGrid1.Columns(5).Alignment = 0
    DBGrid1.Columns(6).Width = 750
    DBGrid1.Columns(6).Alignment = 0
    DBGrid1.Columns(7).Width = 750
    DBGrid1.Columns(7).Alignment = 0
    DBGrid1.Columns(8).Width = 750
    DBGrid1.Columns(8).Alignment = 0
    DBGrid1.Columns(9).Width = 700
    DBGrid1.Columns(9).Alignment = 0
    DBGrid1.Columns(10).Width = 750
    DBGrid1.Columns(10).Alignment = 2
    DBGrid1.Columns(11).Width = 750
    DBGrid1.Columns(11).Alignment = 0
    DBGrid1.Columns(12).Width = 750
    DBGrid1.Columns(12).Alignment = 0
    DBGrid1.Columns(13).Width = 750
    DBGrid1.Columns(13).Alignment = 0
    DBGrid1.Columns(14).Width = 1000
    DBGrid1.Columns(14).Alignment = 0
    
    DBGrid1.SetFocus
    salva = False
    flag = False
    flag1 = True
    ric_casa = ""
    Ric_cod = ""
    ric_des = ""
    flag = True
    flag1 = True
    BT_stop.Visible = False
    succ.Visible = False
    BT_RIC.Visible = True
    ric_des.Locked = False
End Sub

Private Sub Form_Load()
Dim X As Integer
Dim Y As Integer
    X = (Screen.Width - 11400) / 2
    Y = (Screen.Height - 8004) / 2
    F_ARTRMO.Move X, Y
End Sub

Private Sub Form_Resize()
DBGrid1.Width = Me.Width - 250

End Sub

Private Sub Form_Unload(Cancel As Integer)
    End
End Sub

Private Sub Giacenza_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Giacenza.Text <> "" And Not IsNumeric(Giacenza.Text) Then
        tipo_finmsg = 0
        Msg = "La giacenza non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
        End If
        Giacenza.SetFocus
    End If
End Sub

Private Sub IVA_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If IVA.Text <> "" And Not IsNumeric(IVA.Text) Then
        tipo_finmsg = 0
        Msg = "L'IVA non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
        End If
        IVA.SetFocus
    End If
End Sub

Private Sub list_Click()
    F_ARTRMO.Hide
    F_ARTAGG.Show
End Sub

Private Sub mnuesci_Click()
    F_ARTRMO.Hide
    F_MENU.Show
End Sub

Private Sub mnuins_Click()
    F_ARTRMO.Hide
    F_ARTINS.Show
End Sub

Private Sub modtut_Click()
    F_ARTRMO.Hide
    F_ARTMTU.Show
End Sub

Private Sub Prezzo_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Prezzo.Text <> "" And Not IsNumeric(Prezzo.Text) Then
        tipo_finmsg = 0
        Msg = "Il prezzo non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
        End If
        Prezzo.SetFocus
    End If
End Sub

Private Sub ric_casa_Change()
Dim trovato As Boolean
Dim var_db, var_ins As String
Dim lung As Integer
If flag1 Then
    flag = False
    Ric_cod.Text = ""
    flag = True
    DB_ARTICOLI.Refresh
    var_ins = ric_casa.Text
    lung = Len(var_ins)
    While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato
        var_db = DB_ARTICOLI.Recordset("CASA")
        var_db = Left(var_db, lung)
        If var_db = var_ins Then
            trovato = True
            ric_casa.SetFocus
        Else
            DB_ARTICOLI.Recordset.MoveNext
        End If
    Wend
    If DB_ARTICOLI.Recordset.EOF Then
         DB_ARTICOLI.Refresh
         ric_casa.SetFocus
    End If
    pos_ric = DB_ARTICOLI.Recordset.AbsolutePosition
End If
End Sub

Private Sub ric_cod_Change()
Dim trovato As Boolean
Dim var_db, var_ins As String
Dim lung, pos, I As Integer
If flag Then
    var_ins = Ric_cod.Text
    If ric_casa = "" Then
        DB_ARTICOLI.Refresh
        pos_ric = DB_ARTICOLI.Recordset.AbsolutePosition
    End If
    lung = Len(var_ins)
    While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato
        If Ric_cod = "" Then
            DB_ARTICOLI.Refresh
            For I = 1 To pos_ric
                DB_ARTICOLI.Recordset.MoveNext
            Next I
            Ric_cod.SetFocus
        End If
        var_db = DB_ARTICOLI.Recordset("CODICE")
        var_db = Left(var_db, lung)
        If var_db = var_ins Then
            trovato = True
            Ric_cod.SetFocus
        Else
            DB_ARTICOLI.Recordset.MoveNext
        End If
    Wend
    If DB_ARTICOLI.Recordset.EOF Then
         If ric_casa = "" Then
            DB_ARTICOLI.Refresh
            Ric_cod.SetFocus
         Else
            DB_ARTICOLI.Refresh
            For I = 1 To pos_ric
                DB_ARTICOLI.Recordset.MoveNext
            Next I
            Ric_cod.SetFocus
         End If
    End If
End If
End Sub

Private Sub Ricarico_LostFocus()
Dim tipo_finmsg As String
Dim Msg As String
    If Ricarico.Text <> "" And Not IsNumeric(Ricarico.Text) Then
        tipo_finmsg = 0
        Msg = "Il ricarico non è in formato numerico"
        If MsgBox(Msg, tipo_finmsg, "Inserimento Dati Articoli") = 1 Then
        End If
        Ricarico.SetFocus
    End If
End Sub

Private Sub sta_Click()
    F_ARTRMO.Hide
    F_ARTSTA.Show
End Sub

Private Sub succ_Click()
Dim pos_str, tipo_finmsg, I As Integer
Dim var_db, Msg As String
Dim trovato As Boolean
    trovato = False
    If Not (DB_ARTICOLI.Recordset.AbsolutePosition = 1 And cont = 2) Then
        DB_ARTICOLI.Recordset.MoveNext
    End If
    While cont < 3 And Not trovato
        While (Not DB_ARTICOLI.Recordset.EOF) And Not trovato And cont < 3
            If DB_ARTICOLI.Recordset.AbsolutePosition >= pos_db And cont = 2 Then
                cont = 3
            End If
            var_db = DB_ARTICOLI.Recordset("DESCRIZIONE")
            pos_str = InStr(var_db, ric_des.Text)
            If pos_str > 0 Then
                trovato = True
            Else
                DB_ARTICOLI.Recordset.MoveNext
            End If
        Wend
        If DB_ARTICOLI.Recordset.EOF Then
            DB_ARTICOLI.Refresh
            cont = cont + 1
        End If
    Wend
    If cont >= 3 Then
        tipo_finmsg = 0
        Msg = "ATTENZIONE: Tutte le occorrenze della parola sono state trovate"
        If MsgBox(Msg, tipo_finmsg, "Ricerca Articolo") = 1 Then
            ric_des.SetFocus
            BT_stop.Visible = False
            succ.Visible = False
            BT_RIC.Visible = True
            ric_des.Locked = False
        End If
    End If
End Sub



spero qualcuno mi possa riuscire a dare una mano grazie a tutti comunque per la cortesia e la
celerita delle risposte


Ultima modifica effettuata da islington 26/06/22 22:51
27/06/22 5:25
nessuno
Spiegati.

Che succede con quella chiamata? Se non dai tutti i dettagli su cosa non funziona non si potrà mai rispondere.
Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.
27/06/22 6:49
islington
ciao, grazie per l'aiuto,
allora quella chiamata dovrebbe essere automatica ,
quando entri nel dei preventivi , infatti viene chiamato
nel form activate, e quando si opera li tutto ok funziona tutto bne .

quando voglio invece inserire un anticolo o singolo oppure assemblato
che risiede su un altra tabello , con un pulsante si richiama un altro
form dove scelgo l'elenco degli articoli, una volta selto, lo invio al documento,
sichiude qusto form e database, e invio i dati all'altro form per poi
inserirlo nel documento e salvarlo.

normalmente funzione, se metto queto calcolo automatico , quando invio
l'articolo nel form preventivo arriva solo il prezzo e se lo tento di inseirre mi da errore
(logigamente mancando dei dati )

ho provato a chiamarlo in modo diverso in posizioni diverse etc ma senza risultato.. :d:d

grazie a tutti coloro che mi potranno aiutare
27/06/22 7:05
nessuno
Si fa fatica a leggere e seguire, anche per un italiano approssimativo, termini che mancano, frasi poco chiare.

Comunque, devi anche dire DOVE chiami la sub Calcoli perché io non ho il programma funzionante e non posso seguirti. A parte che, ripeto, quel codice, (che viene dal vb4) è orrendo.

Che vuoi dire con [b]"normalmente funzione, se metto queto calcolo automatico"[/B] ???


Hai provato a fare un po' di debugging esaminando le variabili e il contenuto dei campi del record corrente?
Ultima modifica effettuata da nessuno 27/06/22 7:21
Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.
27/06/22 7:20
islington
ciao come ho premesso è una cosa discretamente vecchia, che comunque funziona abbastanza bene ,
in quelle cose che fa.

te lo ho detto viene chiamato dal form activate nel form preins.

ora come gia premesso io non sono un granchè ma e una cosa a uso interno che fa delle cose specifiche
che altri programmi non fanno. mi basterebbe un consiglio
ti posteri tutto il programma ma e lunghissimo.

grazie per l'aiuto.


27/06/22 7:39
nessuno
Se vuoi far capire agli altri devi rispondere alle domande, altrimenti è tempo perso.

Che vuoi dire "normalmente funziona, se metto questo calcolo automatico"???

E la Activate a cui ti riferisci è questa?

Private Sub Form_Activate()
    flag = True
   ' Call Calcoli
    If BT_elart.Visible = False Then
       '  Call Calcoli
        DB_PREV.DatabaseName = CurDir$ & "\SEA.mdb"
        DB_PREV.RecordSource = "select * from db_Prev where numero = " & NORD.Text & " order by ID"
        DB_PREV.Refresh
        Call Calcoli
        flag = False
    
    End If
    DB_ARTICOLI.DatabaseName = CurDir$ & "\SEA.mdb"
    DB_ARTASS.DatabaseName = CurDir$ & "\SEA.mdb"
    DB_STOPRE.DatabaseName = CurDir$ & "\SEA.mdb"
    DB_STOPRE.RecordSource = "select * from db_stopre where numero = " & NORD.Text
    DB_STOPRE.Refresh
    DB_EURO.DatabaseName = CurDir & "\SEA.mdb"
    DB_EURO.RecordSource = "db_EURO"
    DB_EURO.Refresh

' If L_DocP.Visible Then
'   Call riordino
  '  Else
'    Call Calcoli
    Call riordino
  ' End If
    
    
'   salva = False

    
   ' DBGrid1.Columns(0).Visible = False
    'DBGrid1.Columns(1).Visible = False
    'DBGrid1.Columns(2).Width = 620
   ' DBGrid1.Columns(2).Alignment = 2
   ' DBGrid1.Columns(3).Width = 620
   ' DBGrid1.Columns(3).Alignment = 2
   ' DBGrid1.Columns(4).Width = 920
   ' DBGrid1.Columns(4).Alignment = 2
   ' DBGrid1.Columns(5).Width = 4700
   ' DBGrid1.Columns(6).Width = 500
   ' DBGrid1.Columns(6).Alignment = 2
   ' DBGrid1.Columns(7).Width = 723
   ' DBGrid1.Columns(7).Alignment = 2
   ' DBGrid1.Columns(8).Width = 680
   ' DBGrid1.Columns(9).Width = 680
   ' DBGrid1.Columns(10).Width = 680
   ' DBGrid1.Columns(11).Width = 680
   ' DBGrid1.Columns(12).Width = 680
   ' DBGrid1.Columns(13).Width = 680
   ' DBGrid1.Columns(14).Width = 550
   ' DBGrid1.Columns(15).Width = 550
   ' DBGrid1.Columns(16).Width = 680
End Sub


Tutte quelle righe commentate le hai modificate tu? Perché Call Calcoli era chiamato in altri punti?
Perché la Call Calcoli è commentata in altri punti del programma?

Quali sub chiami in sequenza quando non funziona ? (NON INDICARE COSA FAI ma IL NOME delle Sub che chiami).

Ma come pensi che uno possa capire cosa succede dentro un codice scritto così male, senza provarlo con l'ambiente e il debug?
Ultima modifica effettuata da nessuno 27/06/22 7:40
Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.