AlvaroCity
Registered User.
- Local time
 - Today, 12:36
 
- Joined
 - Jul 16, 2016
 
- Messages
 - 70
 
Hi everyone.
I have my db finished but after using it on different computers one of the Dlookup functions stopped working and I don't know why. Basically this to create a pdf along, change the status and decrease the stock.
	
	
	
		
I have been trying to find out what's wrong but I can't find the solution.
I will also post the whole code just in case you can guys see something.
I will appreciate all your help. thank you so much. (It is in Spanish.. sorry)
	
	
	
		
 I have my db finished but after using it on different computers one of the Dlookup functions stopped working and I don't know why. Basically this to create a pdf along, change the status and decrease the stock.
		Code:
	
	
	salbaran = DLookup("[AlbaranNumero]", "tblAlbaran", "[AlbaranID]= " & [AlbaranID])
	I have been trying to find out what's wrong but I can't find the solution.
I will also post the whole code just in case you can guys see something.
I will appreciate all your help. thank you so much. (It is in Spanish.. sorry)
		Code:
	
	
	Private Sub cmdExportar_Click()
    Dim salbaran As Long
    Dim datepedido As String
    Dim prompt As String
    Dim response As Integer
    Dim Ssql As String
    Dim StrAlbaran As Long
    
    prompt = "Estas seguro que quieres actualizar el Stock y crear el Albarán " & Me.txtAlbaranNumero
        
    If IsNull(Me.txtDsumtotal) Then
        MsgBox "Introduce Piezas en el Albarán", vbExclamation + vbOKOnly
    ElseIf IsNull(Me.txtAlbaranID) Then
        MsgBox "Introduce Número de Albarán", vbExclamation + vbOKOnly
    Else
        
        response = MsgBox(prompt, vbQuestion + vbYesNo + vbDefaultButton2, "Actualizar Stock y Exportar Albarán")
                
        If response = vbYes Then
      
        datepedido = Format(Me.txtFecha, "ddmmyyyy")
        
        salbaran = DLookup("[AlbaranNumero]", "tblAlbaran", "[AlbaranID]= " & [AlbaranID])
        
        DoCmd.OutputTo acOutputReport, "rptalbaran", acFormatPDF, "C:\Users\Mecaly\OneDrive - Mecaly\MECALY\Albaranes\Albarán" & " " & salbaran & "-" & datepedido & ".pdf", True
    
        StrAlbaran = Me.txtAlbaranID
               
         
         Ssql = "UPDATE (tblPiezas INNER JOIN tblPedidoDetalle ON tblPiezas.[PiezaID] = tblPedidoDetalle.[PiezaID]) INNER JOIN tblpedidodetallealbaran ON tblPedidoDetalle.[PedidoDetalleID] = tblpedidodetallealbaran.[PedidoDetalleID]" & _
                "SET tblPiezas.Stock= [Stock]-[NumeroPiezas]" & _
                "WHERE (((tblpedidodetallealbaran.AlbaranID)=" & StrAlbaran & "));"
         
         DoCmd.SetWarnings (0)
         
         DoCmd.RunSQL Ssql
         
         DoCmd.SetWarnings (1)
                    
        
        Me.cboIDEstado.Value = 3
        
        Call SetformState
        
        Me.Refresh
        MsgBox "El Albarán se ha exportado con exito", vbExclamation + vbOKOnly, "Exportación con exito"
        
        Else
        
        Close
        
        End If
        
    End If
    
  End Sub