Hi all
I have a continuous form where the user can select a record and click a button to delete it as there are a number of processes i'd like to carry out when they delete the record.
After the delete process has ended i want the button go grey out until another record is selected.
I have 2 buttons on the form a "Delete" and "Delete-Grey" over the top of each other and when the record is selected the "Delete" button with the VBA attached is made visible and the "Delete-Grey" is hidden.
Once the VBA process ends I want to make the "Delete" hidden and the "Delete-Grey" visible but keep getting the error of the button can't have its visible status changed as it has focus.
So i try and set the focus to a different control on the form but it then errors with "can't move the focus to the control".
The weird thing is that as part of the process a second button is also made hidden and that bit works. Here is the VBA:
So the first line (btnClearSelection.Visible) works, but then if i try and set the focus to the lstSupplier it fails with the can't move focus error, if i don't have the set focus step i get the "you can't hide a control that has the focus" as i'm trying to hide the button that the user clicked.
whats even weirder is if i step through after the error comes up it does work so i don't quite understand.
the form is a subform to a navigation form, so i thought it might have something to do with that, but that then doesn't explain the first line of code working and the others not.
just a bit confused
if there is a better way - i have read in places about transparent images but don't quite understand it - to do what i want to do to show/hide buttons depending on what the user is doing i'd appreciate direction
Kind regards
Glen
I have a continuous form where the user can select a record and click a button to delete it as there are a number of processes i'd like to carry out when they delete the record.
After the delete process has ended i want the button go grey out until another record is selected.
I have 2 buttons on the form a "Delete" and "Delete-Grey" over the top of each other and when the record is selected the "Delete" button with the VBA attached is made visible and the "Delete-Grey" is hidden.
Once the VBA process ends I want to make the "Delete" hidden and the "Delete-Grey" visible but keep getting the error of the button can't have its visible status changed as it has focus.
So i try and set the focus to a different control on the form but it then errors with "can't move the focus to the control".
The weird thing is that as part of the process a second button is also made hidden and that bit works. Here is the VBA:
Code:
Me.btnClearSelection.Visible = False
Me.lstSupplier.SetFocus
Me.btnDelConsignment.Visible = False
Me.btnDelConsignmentGrey.Visible = True
So the first line (btnClearSelection.Visible) works, but then if i try and set the focus to the lstSupplier it fails with the can't move focus error, if i don't have the set focus step i get the "you can't hide a control that has the focus" as i'm trying to hide the button that the user clicked.
whats even weirder is if i step through after the error comes up it does work so i don't quite understand.
the form is a subform to a navigation form, so i thought it might have something to do with that, but that then doesn't explain the first line of code working and the others not.
just a bit confused
if there is a better way - i have read in places about transparent images but don't quite understand it - to do what i want to do to show/hide buttons depending on what the user is doing i'd appreciate direction
Kind regards
Glen