Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / April 2005

Tip: Looking for answers? Try searching our database.

GoToControl not working sometimes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Sturdevant - 15 Apr 2005 19:52 GMT
I have a button on a form (Access 2002).  When clicked, the logic opens a
second form upon which is a tab control.  It does a find on a record, and
once found, goes to the Subform that is on the second page of the tab
control.  I use the master/child link to determine which records should be
displayed for the sub form.

I load strPageName with the name of that second tab page, I load
sglMYRecordID with an identifier for the record I want to find, then I use
the following:
           
Open the form.....
DoCmd.GoToControl "My Record ID"
DoCmd.FindRecord sglMYRecordID , acEntire, False, acSearchAll, False,
acCurrent
If strPageName = "My Second Tab" Then
   DoCmd.GoToControl "SubFrm_My_Subform"
End If

This all works as long as there is at least one record returned in the
record source for SubFrm_My_Subform.

BUT if there are no records to be returned in the record source for
SubFrm_My_Subform, I get the ubiquitous "Access has encountered a problem and
I must exit....sorry!" message.

What am I doing wrong?  How can I fix?
Marshall Barton - 15 Apr 2005 20:30 GMT
>I have a button on a form (Access 2002).  When clicked, the logic opens a
>second form upon which is a tab control.  It does a find on a record, and
[quoted text clipped - 22 lines]
>
>What am I doing wrong?  How can I fix?

I don't know what might be going wrong.  IMO, you should
never get an error that does that.

However, you could check the form recordset's RecordCount
property and avoid the issue:

If Me.RecordsetClone.RecordCount > 0 Then
    'your existing code
End If
Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.