Blockin' Registers.

Sorry it took so long to get back to you. It has been a bear today at work and I haven't had time to look in on the forum (as evidenced by the spam that was on here too).

I THINK you can solve your last issue by moving the Me.Block = True to BEFORE the save of the record:

Code:
Private Sub Comando10_Click()

    If Comando10.Caption = "unblock" Then
    Comando10.Caption = "block"
    Me.Block = False
    Me.AllowEdits = True
    Me.AllowDeletions = True
    Me.AllowAdditions = True

Else

[color=blue]    Me.Block = True[/color]
    If Me.Dirty Then Me.Dirty = False
    Comando10.Caption = "unblock"
    
    Me.AllowEdits = False
    Me.AllowAdditions = True
    Me.AllowDeletions = False

End If

End Sub
 
It definitively locks now, thanks, but still ( I can't understand how can they be so many bugs in something as simple as this ) now theres a problem when one unblocks. If the register is saved as unblocked, when one accesses to that specific register, the textboxes are unblocked as they should but the combobox remains blocked. Besides, this bug doesnt just show up when accessing the register, the combobox also remains unblocked sometimes while the botton shows the block option. This error applies just to the combobox, what could it be ?

Besides, in the code you've given me, doesnt the code set the block field as true without necesarily changing the button caption ? Or i'm just reading it wrong ? Wouldnt that lead to an error ?

[ As a last resort, if nothing of this works, maybe we could individually block every field on the form insted of blocking them globaly. ]

Thanks a lot boblarson, i can see youre very busy but still helping me, i apreciate that.
 
Last edited:
I guess its getting hard to get what's wrong, yesterday i've been told access doesnt allow to block anything if my mouse has a field selected. Could that be the source of the mistake ? is there any visual basic command that would let me unselect any object before blocking ? ( that way ill be able to check ).
 
yeah, you could set the focus somewhere else programmatically via code (like to the command button), before blocking.
 
And does anyone know the instruccion for such action ?
 
In the code before the actual code that blocks the other controls just use:

Me.YourCommandButtonNameHere.SetFocus
 
I found the source of all errors, the on current protocol doesnt work as i though it would, if a register is blocked, and i go to the next one, its blocked or unblocked state remains loaded from the last register. So then, something on the code causes the protocol to carry data from one register to another. What can it be ?

[ Im losing it.. ]
 
Final Code.

Just in case somebody gets to need this, ill post the code here, it works properly if i use the individual blocking instead of the allowedits. I hope this will be handy for someone. Boblarson, thanks a lot for everything, ill add to your rep.

Code:
Private Sub Form_Current()

If Me.blocked = True Then

    Me.Comando126.SetFocus
    Comando126.Caption = "unblock"
    
    Me.Proveedor.Locked = True
    Me.Comprador.Locked = True
    Me.Referencia.Locked = True
    Me.Subformulario_Detalles_OC_Consulta.Locked = True
    Me.Plazo_de_Entrega.Locked = True
    Me.Forma_de_Pago.Locked = True
    Me.Notas.Locked = True

Else

    Me.Comando126.SetFocus
    Comando126.Caption = "block"
    
    Me.Proveedor.Locked = False
    Me.Comprador.Locked = False
    Me.Referencia.Locked = False
    Me.Subformulario_Detalles_OC_Consulta.Locked = False
    Me.Plazo_de_Entrega.Locked = False
    Me.Forma_de_Pago.Locked = False
    Me.Notas.Locked = False
    
End If
End Sub

----------


Private Sub Comando126_Click()

    If Comando126.Caption = "unblock" Then
    
    Me.Comando126.SetFocus
    Comando126.Caption = "block"
    Me.blocked = False

    Me.Proveedor.Locked = False
    Me.Comprador.Locked = False
    Me.Referencia.Locked = False
    Me.Subformulario_Detalles_OC_Consulta.Locked = False
    Me.Plazo_de_Entrega.Locked = False
    Me.Forma_de_Pago.Locked = False
    Me.Notas.Locked = False

Else

    Me.Comando126.SetFocus
    Comando126.Caption = "unblock"
    Me.blocked = True
    
    Me.Proveedor.Locked = True
    Me.Comprador.Locked = True
    Me.Referencia.Locked = True
    Me.Subformulario_Detalles_OC_Consulta.Locked = True
    Me.Plazo_de_Entrega.Locked = True
    Me.Forma_de_Pago.Locked = True
    Me.Notas.Locked = True

End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom