Command Buttons & Error Messages & Forms

I want to pass my many thanks to your team for all your inputs!  You've been 
great!!  THANK YOU!!  

Question:  When I insert a command button on the form, I notice that the 
Error event does not recognize my instruction to modify a default error 
message.  On the other hand, I do get the modified message when I click on 
the navigation bar on the form to add a new record.  Again, my command button 
does not recognize the code.  See below

Private Sub Form_Error(DataErr As Integer, Response As Integer)

    If DataErr = 3314 Then
        MsgBox "Please ensure that you enter a caseload type before you 
continue!", vbCritical, "Caseload Type Error Message"
        Response = acDataErrContinue
    Else
        Response = acDataErrDisplay
    End If

End Sub

Here is the command button code

Private Sub Command259_Click()

On Error GoTo Err_Command259_Click

    DoCmd.GoToRecord , , acNewRec
    
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FormSeeker"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command259_Click:
    Exit Sub

Err_Command259_Click:
    MsgBox Err.Description
    Resume Exit_Command259_Click
    
End Sub

NOTE:  I haven't entered any codes to modify the command button, because I 
couldn't make it work.  The command button works fine, but what happens is 
when I get a default error message  "You can't go to the specified record" , 
I click OK and move on.  It would be nice if I could modify it to be more 
specific.   PLEASE don't tell me that it is Error 2105.  I've been in an 
endless loop trying to make it work. I've tried it and still can't change 
that message.    

Thank you again for your help!


0
Utf
2/20/2008 9:22:00 PM
access.forms 6864 articles. 1 followers. Follow

4 Replies
539 Views

Similar Articles

[PageSpeed] 9

Since you've put Error Handling inside the procedure for Command259_Click, 
the code in Form_Error isn't invoked.

Try changing

Err_Command259_Click:
   MsgBox Err.Description
   Resume Exit_Command259_Click

to

Err_Command259_Click:
  Select Case Err.Number
    Case 3314
      MsgBox "Please ensure that you enter a caseload type before you 
continue!", vbCritical, "Caseload Type Error Message"
    Case Else
     MsgBox Err.Description
   End Select
   Resume Exit_Command259_Click


-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"TomP" <TomP@discussions.microsoft.com> wrote in message 
news:7567A1A7-D628-4BC2-A555-9C64F2273110@microsoft.com...
>
> Question:  When I insert a command button on the form, I notice that the
> Error event does not recognize my instruction to modify a default error
> message.  On the other hand, I do get the modified message when I click on
> the navigation bar on the form to add a new record.  Again, my command 
> button
> does not recognize the code.  See below
>
> Private Sub Form_Error(DataErr As Integer, Response As Integer)
>
>    If DataErr = 3314 Then
>        MsgBox "Please ensure that you enter a caseload type before you
> continue!", vbCritical, "Caseload Type Error Message"
>        Response = acDataErrContinue
>    Else
>        Response = acDataErrDisplay
>    End If
>
> End Sub
>
> Here is the command button code
>
> Private Sub Command259_Click()
>
> On Error GoTo Err_Command259_Click
>
>    DoCmd.GoToRecord , , acNewRec
>
>    Dim stDocName As String
>    Dim stLinkCriteria As String
>
>    stDocName = "FormSeeker"
>    DoCmd.OpenForm stDocName, , , stLinkCriteria
>
> Exit_Command259_Click:
>    Exit Sub
>
> Err_Command259_Click:
>    MsgBox Err.Description
>    Resume Exit_Command259_Click
>
> End Sub
>
> NOTE:  I haven't entered any codes to modify the command button, because I
> couldn't make it work.  The command button works fine, but what happens is
> when I get a default error message  "You can't go to the specified record" 
> ,
> I click OK and move on.  It would be nice if I could modify it to be more
> specific.   PLEASE don't tell me that it is Error 2105.  I've been in an
> endless loop trying to make it work. I've tried it and still can't change
> that message.
>
> Thank you again for your help!
>
> 


0
Douglas
2/20/2008 9:31:31 PM
Here is what I entered and it did not work....    I still get the "You can't 
go to the specified record".    

Thank you,


Private Sub Command259_Click()

On Error GoTo Err_Command259_Click

    DoCmd.GoToRecord , , acNewRec
    
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FormSeeker"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command259_Click:
    Exit Sub

Err_Command259_Click:

Select Case Err.Number
    Case 3314
    MsgBox "Please ensure that you enter a caseload type before you 
continue!", vbCritical, "CASELOAD TYPE Error Message"
    Case Else
    MsgBox Err.Description
End Select
    Resume Exit_Command259_Click
    
End Sub


"Douglas J. Steele" wrote:

> Since you've put Error Handling inside the procedure for Command259_Click, 
> the code in Form_Error isn't invoked.
> 
> Try changing
> 
> Err_Command259_Click:
>    MsgBox Err.Description
>    Resume Exit_Command259_Click
> 
> to
> 
> Err_Command259_Click:
>   Select Case Err.Number
>     Case 3314
>       MsgBox "Please ensure that you enter a caseload type before you 
> continue!", vbCritical, "Caseload Type Error Message"
>     Case Else
>      MsgBox Err.Description
>    End Select
>    Resume Exit_Command259_Click
> 
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> 
> "TomP" <TomP@discussions.microsoft.com> wrote in message 
> news:7567A1A7-D628-4BC2-A555-9C64F2273110@microsoft.com...
> >
> > Question:  When I insert a command button on the form, I notice that the
> > Error event does not recognize my instruction to modify a default error
> > message.  On the other hand, I do get the modified message when I click on
> > the navigation bar on the form to add a new record.  Again, my command 
> > button
> > does not recognize the code.  See below
> >
> > Private Sub Form_Error(DataErr As Integer, Response As Integer)
> >
> >    If DataErr = 3314 Then
> >        MsgBox "Please ensure that you enter a caseload type before you
> > continue!", vbCritical, "Caseload Type Error Message"
> >        Response = acDataErrContinue
> >    Else
> >        Response = acDataErrDisplay
> >    End If
> >
> > End Sub
> >
> > Here is the command button code
> >
> > Private Sub Command259_Click()
> >
> > On Error GoTo Err_Command259_Click
> >
> >    DoCmd.GoToRecord , , acNewRec
> >
> >    Dim stDocName As String
> >    Dim stLinkCriteria As String
> >
> >    stDocName = "FormSeeker"
> >    DoCmd.OpenForm stDocName, , , stLinkCriteria
> >
> > Exit_Command259_Click:
> >    Exit Sub
> >
> > Err_Command259_Click:
> >    MsgBox Err.Description
> >    Resume Exit_Command259_Click
> >
> > End Sub
> >
> > NOTE:  I haven't entered any codes to modify the command button, because I
> > couldn't make it work.  The command button works fine, but what happens is
> > when I get a default error message  "You can't go to the specified record" 
> > ,
> > I click OK and move on.  It would be nice if I could modify it to be more
> > specific.   PLEASE don't tell me that it is Error 2105.  I've been in an
> > endless loop trying to make it work. I've tried it and still can't change
> > that message.
> >
> > Thank you again for your help!
> >
> > 
> 
> 
> 
0
Utf
2/21/2008 1:40:00 PM
Change

    Case Else
      MsgBox Err.Description

to

    Case Else
      MsgBox Err.Number & ": " & Err.Description

You'll get the error number (followed by a colon) before the error message.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"TomP" <TomP@discussions.microsoft.com> wrote in message 
news:5F097171-B13D-4682-8981-07B8B53D7F85@microsoft.com...
> Here is what I entered and it did not work....    I still get the "You 
> can't
> go to the specified record".
>
> Thank you,
>
>
> Private Sub Command259_Click()
>
> On Error GoTo Err_Command259_Click
>
>    DoCmd.GoToRecord , , acNewRec
>
>    Dim stDocName As String
>    Dim stLinkCriteria As String
>
>    stDocName = "FormSeeker"
>    DoCmd.OpenForm stDocName, , , stLinkCriteria
>
> Exit_Command259_Click:
>    Exit Sub
>
> Err_Command259_Click:
>
> Select Case Err.Number
>    Case 3314
>    MsgBox "Please ensure that you enter a caseload type before you
> continue!", vbCritical, "CASELOAD TYPE Error Message"
>    Case Else
>    MsgBox Err.Description
> End Select
>    Resume Exit_Command259_Click
>
> End Sub
>
>
> "Douglas J. Steele" wrote:
>
>> Since you've put Error Handling inside the procedure for 
>> Command259_Click,
>> the code in Form_Error isn't invoked.
>>
>> Try changing
>>
>> Err_Command259_Click:
>>    MsgBox Err.Description
>>    Resume Exit_Command259_Click
>>
>> to
>>
>> Err_Command259_Click:
>>   Select Case Err.Number
>>     Case 3314
>>       MsgBox "Please ensure that you enter a caseload type before you
>> continue!", vbCritical, "Caseload Type Error Message"
>>     Case Else
>>      MsgBox Err.Description
>>    End Select
>>    Resume Exit_Command259_Click


0
Douglas
2/21/2008 1:56:02 PM
Thank you so much!   It finally worked!  The error code is 2105 and I changed 
it on the command button.  See below.  

Observation:  If I didn't use the command button to add a new record and use 
the navigation button on the main form, the code to modify the error message 
would be 3314.  

Have a great day!!! 

Private Sub Command259_Click()

On Error GoTo Err_Command259_Click

    DoCmd.GoToRecord , , acNewRec
    
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FormSeeker"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command259_Click:
    Exit Sub

Err_Command259_Click:

Select Case Err.Number
    Case 2105
    MsgBox "Please ensure that you enter a caseload type before you 
continue!", vbCritical, "CASELOAD TYPE Error Message"
    Case Else
    MsgBox Err.Number & ":" & Err.Description
    
    End Select
    Resume Exit_Command259_Click
    
End Sub

"Douglas J. Steele" wrote:

> Change
> 
>     Case Else
>       MsgBox Err.Description
> 
> to
> 
>     Case Else
>       MsgBox Err.Number & ": " & Err.Description
> 
> You'll get the error number (followed by a colon) before the error message.
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> 
> "TomP" <TomP@discussions.microsoft.com> wrote in message 
> news:5F097171-B13D-4682-8981-07B8B53D7F85@microsoft.com...
> > Here is what I entered and it did not work....    I still get the "You 
> > can't
> > go to the specified record".
> >
> > Thank you,
> >
> >
> > Private Sub Command259_Click()
> >
> > On Error GoTo Err_Command259_Click
> >
> >    DoCmd.GoToRecord , , acNewRec
> >
> >    Dim stDocName As String
> >    Dim stLinkCriteria As String
> >
> >    stDocName = "FormSeeker"
> >    DoCmd.OpenForm stDocName, , , stLinkCriteria
> >
> > Exit_Command259_Click:
> >    Exit Sub
> >
> > Err_Command259_Click:
> >
> > Select Case Err.Number
> >    Case 3314
> >    MsgBox "Please ensure that you enter a caseload type before you
> > continue!", vbCritical, "CASELOAD TYPE Error Message"
> >    Case Else
> >    MsgBox Err.Description
> > End Select
> >    Resume Exit_Command259_Click
> >
> > End Sub
> >
> >
> > "Douglas J. Steele" wrote:
> >
> >> Since you've put Error Handling inside the procedure for 
> >> Command259_Click,
> >> the code in Form_Error isn't invoked.
> >>
> >> Try changing
> >>
> >> Err_Command259_Click:
> >>    MsgBox Err.Description
> >>    Resume Exit_Command259_Click
> >>
> >> to
> >>
> >> Err_Command259_Click:
> >>   Select Case Err.Number
> >>     Case 3314
> >>       MsgBox "Please ensure that you enter a caseload type before you
> >> continue!", vbCritical, "Caseload Type Error Message"
> >>     Case Else
> >>      MsgBox Err.Description
> >>    End Select
> >>    Resume Exit_Command259_Click
> 
> 
> 
0
Utf
2/21/2008 5:27:04 PM
Reply:

Similar Artilces:

CRM 3.0 Exchange Email Router Install Error
Hi Everyone, I have installed CRM 3.0 on WinSvr2003 Std and the site is up and running error free. When I try to install the Exchange Email Router on our Exchange server (WinSvr2003 Std/Exchange 2003) I get the following error: "Setup cannot connect to the Microsoft CRM server. This might indicate that the server is down. (The request failed with HTTP status 403: Forbidden.)" I have checked all of my IIS settings and I am using Integrated Windows Authentication and I am not using SSL. I have gone through everything multiple times and have no idea what the problem is. Ple...

Send Error: What exactly is relaying
This is a multi-part message in MIME format. --------------060203050605090002020204 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Lately, I have been getting this message when trying to email from home, using my work email address: Your message did not reach some or all of the intended recipients. Subject: RE: CARFAX Hot Lead Sent: 1/31/2005 8:48 AM The following recipient(s) could not be reached: 'gordon140a@att.net' on 1/31/2005 8:48 AM 530 5.7.1 Relaying not allowed: (And then is lists the email a...

Form Loading Graphic/Script
Hi, I have a fairly intense DB and the forms can take a few seconds to load the data. Not terrible long so i am not too concerned about reducing the load time but i would like to know if there is anyway of notifying the user that the DB is doing something. Is this possible? Steve ...

How do I put input boxes and sumbit buttons in?
How do I put input boxes and sumbit buttons in excel vba? I am trying to make a address book manually using Excel VBA. Is there a way I can record multiple information into Excel after submitting info. All i have so far is being able to submit one bit of information into excel but I dont think it will stay if I save it. Like is there a way I can group multiple address information using excel VBA? If so how? What you want to do is not clear. Please post back and give us a step-by-step procedure of what you want to do and what you want Excel to do. HTH Otto "mikstr14" <m...

Cannot delete Public Folder
Howdi, I know the answer to this question, i think, but just wanted to triple check. Basically, I had an exchange server go down (wasn't stable but usuable, just) due to hardware failure and the back ups on that server were corrupt as well. So in the small amount of time available I had to .pst all mailboxes (that was long) and recreate a new exchange box. However, I totally forgot to manage the Public Folders on that box. Now, obvioulsy, when i try and access those Puclic foldsers (in ExchAdmin or Outlook) I get 'the information store is not availbale' error. Is there a...

print preview command in Excel
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) I just upgraded to office 2008 for Mac and can not find the &quot;print preview&quot; command in Excel I had in my previous version and that is available in Word 2008. Was it removed? > On 11/4/09 8:43 AM, in article 59b7feef.-1@webcrossing.caR9absDaxw, <br> > &quot;sprint1005@officeformac.com&quot; wrote: <br> > <br> > > Version: 2008 <br> > > Operating System: Mac OS X 10.6 (Snow Leopard) <br> > > <br> > > I just upgraded to office ...

Error when using XMLTextReader to read HTML
I have some simple HTML I'm trying to read with the XMLTextReader. As in the MSDS examples, I set up a loop to read each XML node: while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: Console.WriteLine("<{0}>", reader.Name); break; case XmlNodeType.Text: Console.WriteLine(reader.Value); break; case XmlNodeType.Attribute: Console.WriteLine(reader.Value); break; default: Console.WriteLine(reader.NodeType); break; } } The reader moves along fine until it attempts...

Custom Menu
I want to create a button on Oppurtunity Form that opens a url and passes current user as part of the query string. I am able to create the button using isv.config file. Someone had earlier posted code below regarding a similar scenario. 1. they didnt say where to place the htm file. i have saved it in root of crm server...wwwroot when i try to open the url, it gives an error ... 'windows.opener.crmForm' is null or not an object. Does any one know how to fix this ? OR know where to place the htm file so it know what crmForm is ... OR A different way to open a url .. ...

error #2
I'm just starting out. When I go to open a template I get the error message "Publisher cannot complete the operation." Any help is appreciated. Anne Baker A trial? There is a wealth of information here for that error if you are using Windows XP. http://www.css-networks.com/2008/08/publisher-cannot-complete-the-operation-on-windows-xp.html -- Mary Sauer http://msauer.mvps.org/ "Anne Baker" <Anne Baker@discussions.microsoft.com> wrote in message news:4DF44333-A8F4-4B6A-919D-4DE36ED4DCF8@microsoft.com... > I'm just starting out. When I...

error 0x80040116 solved?
I created a new pst to solve error 0x80040116 (posted July 25.03) everything works fine but I cannot access old emails. Any ideas would be appreciated. Thanks in advance for any help. Before I created a new pst chkdsk/scandisk would not run. chkdsk-unusual error occurred scandisk-file not accessible Since the creation of my new pst, I can now access my old emails after I ran chkdsk/scandisk 5 times in succession. So far everything seems back to normal. >-----Original Message----- >I suspect that there is a disk error in one of the sectors used by your old >PST. I...

macros will not assign to buttons
Help! I cannot assign macros to my custom buttons. The dialog box appears and I can select a macro but it does not save to the button. I believe this is related to another problem I had - which was my personal.xls file did not load on start even though it was in the xl start folder. I fixed that - it was disabled by excel which I fixed by going to about excel - disabled files and selecting enable. Now personal.xls loads - but the macros will not assign. What type of button? From Tools>Customize>Commands>Macros? These customizations are stored in a file named Excel(x).xlb wher...

Form size changing
Access 2003. I have an input form with a command button that executes a stored procedure (through a pass-through query) to write records to a table in SQL Server. On click, the form restores itself. I don't have any code changing the size. There are several things happening, pass through query being run, null values being checked etc. I can paste the code, rather long, but I was hoping there might be a few things to look for first that could be causing this. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201005/1 ...

ESEutil commands
I need a step by step guide on using eseutil. I need to learn how to use this tool to commit the logs to the database On Tue, 23 Nov 2004 18:09:02 -0800, "Ed" <Ed@discussions.microsoft.com> wrote: >I need a step by step guide on using eseutil. I need to learn how to use this >tool to commit the logs to the database eseutil/? A full online backup of the store will commit the logs. What exactly are you trying to accomplish? I have another site that will not have a backup solution in place until next month so i would to know how to flush the logs using this utility ...

Creating custom buttons #2
Hello, I would like to create screens of buttons so that the operators of the register can simply press a button to add an item for a sale. The system will be used at the end of a cafeteria type food line and I need to speed up the check out process. What I am thinking is having 3 buttons on one screen, Hot Food, Drinks, and Candy/Snacks. Then when the cashier presses Hot Food, another screen comes up that displays 1 button for each of the 16 current Hot Food items. When 1 of those items is selected, the Hot Food button screen should remain open until the user presses a Back button. ...

Command Button #4
I'm trying to create a command button to clear filters in my spreadsheet. I don't know how to write the commands, but can recored a macro and run it fine. I tried pasting that macro into the button....and I had it working then messed it up. Now when I click on the button, nothing happens. The code currently associated to the button is below. I really don't want Criteria1 to = 'Reject', but the one time the button worked if no filter was set and the button clicked, an error was returned. The only way I could make it work was to force a filter as part of the macro. How...

Mailbox size limits message
When a user exceeds the limits placed on their mailbox they recieve an email. Anyone know if this message can be modified ? Since it gets translated by MS in different language versions, I would suspect that it is a template. I've tried searching the disk without noticing anything.. but there's a lot to search and I could have missed it. Regards Ian Murphy Yes it can be modified, it is a DLL, you have to call Microsoft so they give you a DLL editor and the name of the dll you have to modify "Ian Murphy" <ian@integra.antispam.-xp.com> wrote in message news:18cqbkx...

command
how do you use command. A lot of computer people use it but how do we use it? Aaron You've reached a newsgroup dedicated to supporting the use of Microsoft Access, a relational database product. I don't see anything in your post that suggests you are asking about MS Access. Please post to a newsgroup that supports the area covered by your post. Regards Jeff Boyce Microsoft Office/Access MVP "aaron" <aaron_t_d@hotmail.com> wrote in message news:78CB1423-55B3-40A1-8BF5-D4615E816057@microsoft.com... > how do you use command. A lot of computer people use i...

Every new email
XP Pro SP1, Win2003, Office 2003 Pro SP1 via Assigned Computer Policy in GPO. We had a working Office 2003 Pro admin point for months. We setup a new package to rollout SP1 per MS directions. We simply added a policy pointing to the new installation. Upon the first few end-user logins, all seemed to work as designed. Then all hell broke loose. Some users started having problems attaching Word documents (Word only, all others work) to Outlook outgoing messages. It would throw error 1394 "Invalid characters exist in Application Data". Other users have a very different, yet huge...

Set Increment on Spin Button to 0.1
I'm using a spin button from the control toolbar to increase the value in a cell. the min value i want is 0 the maximum is 2 but i want it to increase by 0.1 in the properties this doesn't seem to be allowed help!!!! Thanx Mark Mark, Here is one way. Link your spinbutton to an unused cell (I use) A15. Set the max to 20. Then in code, set the real cell's value like so Private Sub SpinButton1_SpinUp() Range("A16").Value = Range("A15").Value / 10 End Sub Private Sub SpinButton1_SpinDown() Range("A16").Value = Range("A15").Valu...

Communicating between forms
I am REALLY having trouble with this. I have a small pop-up form with a combo box. Within this combo box are many part numbers. There is a "Go" button beside of the combo box. What I am trying to get to happen is that when the user picks a part number from the combo box, then presses the "Go" button, that another form opens displaying the records for that part number. I really want to be able to use the "Go" button instead of this happening autmatically when the user steps off of the control. My pop up form combo box is called Combo11. The "Go" bu...

command boxes from menu
I was working on word 2003, I had copied a portion of an online ebook to paste onto a new document, when I did right click to paste it on the doc. the command box appears outlined, no word commands, it's like a ghost. I then went to the menu at the top to Edit and find paste to do it from there and the same thing appeared; an outline of the command box, no word commands, it's like a ghost. I tried to pretend the words were there just not visible and moved my cursor to the position in which I thought paste was and clicked but nothing happened. Has anybody ever had this ...

Socket Notification Sink Error #2
Hi, We use CAsyncSocket after several hours we get "Socket Notification Sink" error message box. We do not use gracefully close Is that can solve the problem? Thanks, Itsik itsik wrote: > > Hi, > We use CAsyncSocket after several hours we get "Socket Notification > Sink" error message box. We do not use gracefully close Is that can > solve the problem? > Thanks, > Itsik Yes, a gracefull close might solve the problem. I think the error means there is an attempt to process a data received notification on a closed socket. A gracefull close will flush ...

Exch 2003 - Stopped MTA Stacks Service
We've got two Exchange 2003 servers in native mode. I had read that you don't need the MTA Stacks service running in this configuration, so I stopped the service on both boxes yesterday. I came in this morning and there were hundreds of emails queued up on both servers queues to each other. When I highlighted the queue on one of the servers it said the other server was unreachable. I then found that we had no DNS entries for these servers in our AD DNS. I added them, and also added MX records and mail started flowing between them again. Does the MTA Stacks service provide some kind of ...

command
still learning of the sql command HOW TO DISABLE XP_CMDSHELL AND DISABLE BOTH MAIL PROCEDURES ...

Popup Outlook with html formatted message
Hi, trying to use MAPISendMail from MAPI32.DLL to open default mail client / outlook for html formatted body with no success. It works perfectly for no html formated body but for html formated it simply encodes all html tags :( Using outlook objects I can only use outlook... It is done in Picassa - any idea how? Any help would be appreciated! ...