G
gsnidow via AccessMonster.com
Greetings folks. I have a form and subform. I am trying to prevent server
messages from popping up, because they confuse users. I want to ensure that
a non-nullable field on the subform is populated before the focus leaves the
subform. I have put the following code behind the exit event of the subform.
Private Sub frmSearchEWOSub_Exit(Cancel As Integer)
On Error GoTo Err_frmSearchEWOSub_Exit
Dim strSQLR As String
strSQLR = "DELETE tblroadblocks " & _
"WHERE r.id = '" & frmSearchEWOSub.Form.txtID & "' " & _
"FROM tblroadblocks r"
If Me.frmSearchEWOSub.SourceObject = "frmSearchEWO_Roadblocks" Then
If Len("" & Me.frmSearchEWOSub.Form.txtroadblock) = 0 Then
If MsgBox("The roadblock description field is blank. This record
will be deleted if there is no description. Do you want to delete this
record?", vbYesNo, "text box") = vbYes Then
MsgBox "enter delete code here", vbOKOnly 'This is where I will
run delete code
Else: Me.frmSearchEWOSub.Form.txtroadblock.SetFocus 'this is what
I can not figure out
End If
End If
End If
Exit_frmSearchEWOSub_Exit:
Exit Sub
Err_frmSearchEWOSub_Exit:
MsgBox Err.Description
Resume Exit_frmSearchEWOSub_Exit
End Sub
everything works except for the line where I am trying to set the focus to
the control I want populated. Any ideas?
Greg Snidow
messages from popping up, because they confuse users. I want to ensure that
a non-nullable field on the subform is populated before the focus leaves the
subform. I have put the following code behind the exit event of the subform.
Private Sub frmSearchEWOSub_Exit(Cancel As Integer)
On Error GoTo Err_frmSearchEWOSub_Exit
Dim strSQLR As String
strSQLR = "DELETE tblroadblocks " & _
"WHERE r.id = '" & frmSearchEWOSub.Form.txtID & "' " & _
"FROM tblroadblocks r"
If Me.frmSearchEWOSub.SourceObject = "frmSearchEWO_Roadblocks" Then
If Len("" & Me.frmSearchEWOSub.Form.txtroadblock) = 0 Then
If MsgBox("The roadblock description field is blank. This record
will be deleted if there is no description. Do you want to delete this
record?", vbYesNo, "text box") = vbYes Then
MsgBox "enter delete code here", vbOKOnly 'This is where I will
run delete code
Else: Me.frmSearchEWOSub.Form.txtroadblock.SetFocus 'this is what
I can not figure out
End If
End If
End If
Exit_frmSearchEWOSub_Exit:
Exit Sub
Err_frmSearchEWOSub_Exit:
MsgBox Err.Description
Resume Exit_frmSearchEWOSub_Exit
End Sub
everything works except for the line where I am trying to set the focus to
the control I want populated. Any ideas?
Greg Snidow