UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Combobox After Update, Access 2016    
 
   
mike60smart
post Aug 2 2020, 09:57 AM
Post#1


UtterAccess VIP
Posts: 14,077
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone

I have the following Code in the After Update of a Combobox.

How can I trap for errors if the user tries to exit the Combobox after they have entered a wrong Value in the Combobox and then uses the backspace key to delete the value entered.

The error they get is as follows:-

Attached File  error.JPG ( 17.37K )Number of downloads: 3


CODE
Private Sub cboSearch_AfterUpdate()

10        On Error GoTo cboSearch_AfterUpdate_Error
20    DoCmd.OpenForm "frmCaseNrList", , , "[CaseReportedID]=" & [cboSearch]

          
30        On Error GoTo 0
40        Exit Sub

cboSearch_AfterUpdate_Error:

50        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cboSearch_AfterUpdate, line " & Erl & "."

End Sub

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
theDBguy
post Aug 2 2020, 10:02 AM
Post#2


UA Moderator
Posts: 78,612
Joined: 19-June 07
From: SunnySandyEggo


Hi Mike. Try adjusting your code to this:
CODE
DoCmd.OpenForm "frmCaseNrList", , , "[CaseReportedID]=" & Nz([cboSearch],0)

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
mike60smart
post Aug 2 2020, 10:31 AM
Post#3


UtterAccess VIP
Posts: 14,077
Joined: 6-June 05
From: Dunbar,Scotland


Hi theDBGuy

Well that gets rid of the error message but now when I tab out of the Combobox it opens the Form "frmCaseNrList" with just theForm Header Displayed.

Is there any way to stop this happening?


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
moke123
post Aug 2 2020, 11:03 AM
Post#4



Posts: 1,391
Joined: 26-December 12
From: Berkshire Mtns.


You could go back to trapping the error

CODE
Private Sub cboSearch_AfterUpdate()

10        On Error GoTo cboSearch_AfterUpdate_Error
20    DoCmd.OpenForm "frmCaseNrList", , , "[CaseReportedID]=" & [cboSearch]

          
30        On Error GoTo 0
40        Exit Sub

cboSearch_AfterUpdate_Error:

     If err.number = 3075 then
         'msgbox if you want one
         exit sub
     end if

50        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cboSearch_AfterUpdate, line " & Erl & "."

End Sub
Go to the top of the page
 
tina t
post Aug 2 2020, 11:24 AM
Post#5



Posts: 6,744
Joined: 11-November 10
From: SoCal, USA


hi Mike, you could avoid the error by checking the control first, as

CODE
    If Len(Me!cboSearch & "") > 0 Then
        DoCmd.OpenForm "frmCaseNrList", , , "[CaseReportedID]=" & [cboSearch]
    End If

hth
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 
mike60smart
post Aug 2 2020, 11:27 AM
Post#6


UtterAccess VIP
Posts: 14,077
Joined: 6-June 05
From: Dunbar,Scotland


Hi Tina

Perfect Manythanks

kisses.gif pompom.gif

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
tina t
post Aug 2 2020, 03:32 PM
Post#7



Posts: 6,744
Joined: 11-November 10
From: SoCal, USA


you're welcome, Mike, we were all happy to help. :) tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    6th August 2020 - 05:53 AM