Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

runtime error 2110 microsoft access can't move the focus to the contro

Status
Not open for further replies.

JLHodge

Technical User
Apr 8, 2009
2
Hi,

I am pretty much a novice to Access, and especially VBS, but none-the-less I have been put to work trying to redo and fix an access database at work. I am unsure of what I did, but I now am getting the error: "runtime error 2110 microsoft access can't move the focus to the control Option 1" when I try to go into datasheet view for the switchboard. I even tried deleting the whole switchboard and restarting it, but still get the error. Other weird part is, I opened the original database (I am working with a renamed copy as to not upset day-to-day operations at work) and it now is doing it also. Below is the code that pops up when it says to debug, the line that is highlighted is "Me![Option1].SetFocus":

Private Sub FillOptions()
' Fill in the options for this switchboard page.

' The number of buttons on the form.
Const conNumButtons = 8

Dim dbs As Database
Dim rst As Recordset
Dim strSQL As String
Dim intOption As Integer

' Set the focus to the first button on the form,
' and then hide all of the buttons on the form
' but the first. You can't hide the field with the focus.
Me![Option1].SetFocus
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Next intOption

' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set dbs = CurrentDb()
strSQL = "SELECT * FROM [Switchboard Items]"
strSQL = strSQL & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID]
strSQL = strSQL & " ORDER BY [ItemNumber];"
Set rst = dbs.OpenRecordset(strSQL)

' If there are no options for this Switchboard Page,
' display a message. Otherwise, fill the page with the items.
If (rst.EOF) Then
Me![OptionLabel1].Caption = "There are no items for this switchboard page"
Else
While (Not (rst.EOF))
Me("Option" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Visible = True
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
rst.MoveNext
Wend
End If

' Close the recordset and the database.
rst.Close
dbs.Close

End Sub


If anyone could help me get back on track (I was pretty close to finishing after working on it for 3 weeks)I would greatly appreciate it.

Thanks,
Jaime
 
Don't open a switchboard in datasheet view.


Switchboard code fires on events and works by being in form view not datasheet view.


FYI... VBS is Visual Basic Scripting and is a lower less robust language than using modules in Access which is VBA, Visual Basic for Applications.
 
Ok, how do I make all of the buttons work on the switchboards without opening it in datasheet view? I have all of our forms working, seemingly at that that is, however it is only when I open the form's themselves. I cannot figure out how to update the switchboard to register all of the buttons it has on/within it.
 
The buttons work in form view, not design view nor datasheet view.

I'm not sure what you mean by your last statement but to add, arrange or remove items from a switchboard; Menu: Tools, Database Utilities, Switchboard Manager. Hmmm... I wonder how you do it in Access 2007 with the ribbon.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top