can't move the focus to the control

Bee

Registered User.
Local time
Today, 18:48
Joined
Aug 1, 2006
Messages
486
Hi

I am trying to write simple code that undoes entering a new record and moves the focus to a mandatory field. I wrote the code below; however, I get this run time error message each time I run it.

DB can't move the focus to the control PlotNum.

My code:
Code:
Private Sub cmbHouseType_BeforeUpdate(Cancel As Integer)
    Forms![frmHouse]![qryHouse2]![PlotNum].SetFocus
    If Forms![frmHouse]![qryHouse2]![PlotNum].Text = "" Then
        Cancel = True
        Me.Undo
        MsgBox "Please enter the Plot Number first, then enter the House Type"
    End If
End Sub

Any help will be very much appreciated
B
 
If it is on the same form and not a subform try using

DoCmd.GoToControl "PlotNum"

Garry
 
I wanted to check it would work before posting....

If it is a subform then, goto the subform first then the control,

DoCmd.GoToControl ("qryHouse2")
DoCmd.GoToControl ("PlotNum")

Garry
 
That worked fine - cheers.
 

Users who are viewing this thread

Back
Top Bottom