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 / January 2005

Tip: Looking for answers? Try searching our database.

Code to prohibit runtime error 2105

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SharonInGa - 29 Jan 2005 01:41 GMT
My form includes a text box with Company names in it and two command buttons:
1.  Add new name  2.  Save data and close.  All possible errors are covered
except when the user presses "Add new name", begins typing in a name and
presses "Add new name" again.   The Run Time Error #2105 appears.  What code
can be used in addition to a message to prohibit a user from making the
mistake of pressing the "Add new name" two times?

   cmdAdd       cmdSave
Allen Browne - 29 Jan 2005 03:09 GMT
It might help to know what code is in the event procedure, but I'm guessing
the message means you cannot go to a new record because you are already at a
new record.

This kind of checking should prevent the problem:

Private Sub cmdAdd_Click()
   If Not Me.NewRecord Then
       If Me.Dirty Then
           RunCommand acCmdSaveRecord
       End If
       RunCommand acCmdRecordsGoToNew
   End If
End Sub

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> My form includes a text box with Company names in it and two command
> buttons:
[quoted text clipped - 7 lines]
>
>    cmdAdd       cmdSave
MacDermott - 29 Jan 2005 12:06 GMT
The code you use would depend on what effect you want to achieve.
If you want to let your users move on to another record when they're already
working on a new one, Allen Browne's code will work fine.
If you want to keep your users from pressing the AddNew button while
entering a new record, one approach would be to check in the form's Current
event, something like this:
   cmdAdd.Enabled=(Me.NewRecord=false)
This will disable the Add button (cmdAdd) if you're on a new record, and
enable it if you're not.
The downside to this approach is that you're not giving your users any
explanation of what's going on.

HTH

> My form includes a text box with Company names in it and two command buttons:
>  1.  Add new name  2.  Save data and close.  All possible errors are covered
[quoted text clipped - 4 lines]
>
>     cmdAdd       cmdSave
 
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.