merce33
Active Member
- Joined
- Oct 27, 2006
- Messages
- 277
I get runtime error 2164 "can't disable a control while it has the focus" when i run the following code. why?
as you can see, i have set the focus on a different control and thus should be able to disable it.
any suggestions? The Barcode textbox under question simply receives a barcode scan. i then want to filter the form based on the scan, enable certain controls, and disable the box that received the scan, such that no other scans can be made until the record is saved.
thanks,
Mike
Code:
With Forms!frmDefectSheets
'main form frmDefectSheets was previously disabled, need to enable it now that
'a scan has been made. turning ON the main form
.AllowEdits = True
.fSubDefectLineItems.Enabled = True
.txtQtyProduced.Enabled = True
'set the focus elsewhere so that me.txtBarcode can be disabled
.SetFocus
.txtQtyProduced.SetFocus
.SetFocus
.txtDateCollected.SetFocus
.SetFocus
.txtQtyProduced.SetFocus
'deactivate barcode textbox until record is saved
'turning OFF the barcode textbox so no scans can be made until a save
'THIS IS WHERE THE ERROR IS OCCURRING, BUT WHY?
Me.txtBarcode.Enabled = False
'set focus on defect sheet form and filter to the scanned record
.SetFocus
DoCmd.ApplyFilter , "idsDefectSheetID = " & Me.txtBarcode.Value
.Refresh
.Requery
'assign date collected time if it didn't already have one
If IsNull(.txtDateCollected) Then .txtDateCollected.Value = Now()
End With
as you can see, i have set the focus on a different control and thus should be able to disable it.
any suggestions? The Barcode textbox under question simply receives a barcode scan. i then want to filter the form based on the scan, enable certain controls, and disable the box that received the scan, such that no other scans can be made until the record is saved.
thanks,
Mike