Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'função para verificar se algum usuário está gerando fatura (para não gerar número de fatura duplicado)
  2. Function verificaGeraFaturaAberto()
  3.  
  4. On Error GoTo erro
  5.  
  6.     Dim Rec113 As ADODB.Recordset
  7.    
  8.     Call Conectar
  9.    
  10.     'seleciona os regitros da tabela ger113
  11.    Set Rec113 = New ADODB.Recordset
  12.     Rec113.Open "SELECT * FROM ger113 WHERE Estado = true AND datevalue(data) = '" & DateValue(dataAberturaForm) & "'", con, adOpenStatic, adLockReadOnly
  13.    
  14.     'caso recordcount maior que zero entra no loop
  15.    Do While Rec113.RecordCount > 0
  16.        
  17.         'fecha a conexao e abre novamente
  18.        Rec113.Close
  19.         Rec113.Open "SELECT * FROM ger113 WHERE Estado = true AND datevalue(data) = '" & DateValue(dataAberturaForm) & "'", con, adOpenStatic, adLockReadOnly
  20.        
  21.         'caso recordcount igual a 0  sai do loop para gerar um novo numero de fatura sem duplicar
  22.        If Rec113.RecordCount = 0 Then
  23.        
  24.             Exit Function
  25.                    
  26.         End If
  27.    
  28.     Loop
  29.    
  30.     Call Desconectar
  31.    
  32. Exit Function
  33.  
  34. erro:
  35. GravaErro err.Description, "verificaGeraFaturaAberto : frmAgendaVis"
  36.  
  37. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement