Refresh command button after Exporting file pdf.

AlvaroCity

Registered User.
Local time
Today, 06:19
Joined
Jul 16, 2016
Messages
70
hello there

I bumped into another problem developing my database.

This time after exporting some data to a pdf. file I want some command buttons to be disable.

I set the me.refresh command but It does not make any difference with reference to this issue.

I was wondering if there is any other command that I could use for this purpose

Please do not hesitate to ask for more information.

If you need I will write the code

Cheers
 
You can't be on a button to disable,so move cursor to a box,THEN disable buttons.


TxtBox.SetFocus
Btn1.enabled =false
Btn2.enabled =false
Docmd.TransferSpreadsheet .....
 
Sorry RanMan256 that´s not what I am looking for

I have a button that exports some data into a file and also disables some buttons. The only thing I want is that after pressing the "Export button", the rest of the buttons that are suppose to be disable, change its properties immediately.
So far I have to move to another record and come back to see the changes.
I was wondering if adding some code to the export button would update this.
I have try me.repaint but it does not work.
any other idea?

Thank you in advance
 
So what is the code you are using ? All the code used to change the button state after the export.
 
Code:
Function SetformState()


    Dim State As AlbaranState
    
    If (Me.cboIDEstado.Value = 1) Then
        State = New_Albaran
    ElseIf (Me.cboIDEstado.Value = 2) Then
        State = InProcess_Albaran
    ElseIf (Me.cboIDEstado.Value = 3) Then
        State = Closed_Albaran
    End If
        
    Me.frmSubAlbaran.Locked = (State = Closed_Albaran)
    Me.txtAlbaranNumero.Enabled = (State = New_Albaran) Or (State = InProcess_Albaran)
    Me.txtFecha.Enabled = (State = New_Albaran) Or (State = InProcess_Albaran)
    Me.cboCliente.Enabled = (State = New_Albaran) Or (State = InProcess_Albaran)
    Me.cmdExportar.Enabled = (State = New_Albaran) Or (State = InProcess_Albaran)
    Me.cmdEliminarPieza.Enabled = (State = New_Albaran) Or (State = InProcess_Albaran)
    Me.cmdfrmPedidoDetalleAlbaran.Enabled = (State = New_Albaran) Or (State = InProcess_Albaran)
 
End Function






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
    Dim AlbaranNum 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(Date, "ddmmyyyy")
        
        salbaran = DLookup("AlbaranNumero", "tblAlbaran", "[AlbaranID]= " & [AlbaranID])
     
        DoCmd.OutputTo acOutputReport, "rptalbaran", acFormatPDF, "c:\users\Alvaro\Desktop\Mecanizados\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
        
        Me.Refresh
        
       [COLOR=Red] DoCmd.RepaintObject acForm, "frmAlbaran"[/COLOR]
                
        MsgBox "El Albarán se ha exportado con exito", vbExclamation + vbOKOnly, "Exportación con exito"
        
        Else
        
        Close
        
        End If
        
    End If
 
Okay - so I assume the function SetformState is called on the forms current event ?
Why not call it in the code for the button push?
 
Yes that is!
Its on the current event.

Im not very good at coding. Could you explain that a little bit more

Thank you Minty
 
Simply call the function in your export code;
Code:
        Me.cboIDEstado.Value = 3
        
        [COLOR="Red"]Call SetformState()[/COLOR]
        
        Me.Refresh
 
Fix it!!!!!

Thank you Minty!!! I really appreciate the way that you share your knowledge!!

Thank you a lot! you made my day!!
 

Users who are viewing this thread

Back
Top Bottom