SetFocus gives run-time error 2110

G

Guest

I have the following code when a calendar is selected and visible to allow
one to choose a date in the ctlChooseFromDate unbound control.

Private Sub calChooseFromDate_Click()
dteFromDate = Me.calChooseFromDate
Me.ctlChooseFromDate = dteFromDate
Me.ctlChooseFromDate.SetFocus
Me.calChooseFromDate.Visible = False
Call Refresh
Exit Sub

End Sub

When the command "Me.ctlChooseFromDate" is executed one gets the run-time
error 2110, "DLB Trucking, Inc. can't move to the control ctlChooseFromDate."
This same code with a different field reference in the setFocus statement
runs correctly in other forms. I have turned off the autocorrect for the
ctlChooseFromDate control on the form.

I have tried setting the focus to other controls on the form, all with the
same resulting error message.

Why can't I set the focus to this or some control on the Form?
 
G

Guest

I've ran into the same problem before, and for reasons I don't know, in some
cases the following bit of code seems to work where setfocus doesnt:

DoCmd.GoToControl ("ctlChooseFromDate")

-Jack
 
G

Guest

--
Cuyler Smith


Dymondjack said:
I've ran into the same problem before, and for reasons I don't know, in some
cases the following bit of code seems to work where setfocus doesnt:

DoCmd.GoToControl ("ctlChooseFromDate")

-Jack


Thanks Jack. I think I solve it. I had the same code in the exit event. I
think that was messing with it somehow. Deleted the exit event procedure and
now it works.

However, if it happens again I will try your suggestion. Weird things
happen in Access 2007 that didn't seem to happen in 2003.

Cuyler~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top