Lost focus Problem

Paul Cooke

Registered User.
Local time
Today, 23:31
Joined
Oct 12, 2001
Messages
288
Hi Guys

could someone tell me how (if it's possible that is) to disable a lostfocus event on a control in the notinlist event?

I have 2 combos for simplicty cbo1 & cbo2. If the user tabs out of cbo1 leaving it empty the lostfocus event triggers - msgbox do you have name yes or no? if they choose No then cbo1 disables and cbo2 enables and everything is fine.

However if they enter a value in cbo1 that is not in the list the notinlist event triggers with msgbot name not in list add yes or no? if they choose yes
cbo1 disables and cbo2 enables and the value is added to the table. but as soon as they select yes at this point the lostfocus event msgbox of cbo1 kicks in.

Is there a way to by pass this with some code in the not in list event?

Hopefully this makes sense. For information I cannot change the way the cbo's work as I do not want allow the users to add anything to the main table but due to the nature of the data entry they must be able to enter new values so cbo2 stores them in a secondary table

many thanks for any advice offered !
 
Hi John thanks for the reply

as below

Code:
If IsNull(Me.cboProductionEmployerName) = True Then
    
    Me.cboProductionEventTitleID.Enabled = False
    
    Beep
    Msgresponse = MsgBox("You have not entered a Production or Employer name." _
    & vbCrLf & vbCrLf & "Do you have a Production or Event Title?", vbQuestion + vbYesNo, "Name Or Title Required")
    
    
    If Msgresponse = vbYes Then
    
    Me.cboProductionEventTitleID.Enabled = True
    Me.cboProductionEventTitleID.SetFocus
    Me.txtAccidentDate.Enabled = True
    Me.txtAccidentTime.Enabled = True
    Me.txtAccidentLocation.Enabled = True
    Me.txtAccidentDetails.Enabled = True
    Me.cboStaffName.Enabled = True
    
    Else
    
    MsgBox "As you do not have either a Production or Employer name or a Production or Event Title please enter 'Unknown' in the highlighted box.", vbInformation, "Unknown"
    
    Me.cboProductionEventTitleID.Enabled = False
    Me.cboProductionEmployerName.Enabled = False
    Me.cboProductionEmployerName.Visible = False
    Me.cboProductionEmployerName2.Visible = True
    Me.cboProductionEmployerName2.Enabled = True
    Me.cboPatientOccupation.SetFocus
    Me.cboProductionEmployerName2.SetFocus
    Me.txtAccidentDate.Enabled = True
    Me.txtAccidentTime.Enabled = True
    Me.txtAccidentLocation.Enabled = True
    Me.txtAccidentDetails.Enabled = True
    Me.cboStaffName.Enabled = True
 

    End If
End If
 

Users who are viewing this thread

Back
Top Bottom