Advertisement

06.08.2008 at 07:46PM PDT, ID: 23467936
[x]
Attachment Details

How to generate error message that contains a parameter?

Asked by angie_angie in Access Coding/Macros, Visual Basic Programming, SQL Query Syntax

Tags: MS Access, VBA

Hi experts,

I'm trying to insert records from tbl_A to tbl_B. Each record in tbl_B contains a unique caseID. I want to prompt an error message if any of the records in tbl_A that I want to insert into tbl_B already exist in tbl_B. However, I want the message to show which record(s) are those already existed ones by revealing their caseID(s), which means the error message that I use need to contain a parameter instead of pure strings.  Moreover, I want to give two options for user to choose as either to proceed or to cancel. For the moment I can only come up with the following codes that display a simple message upon occurance and exits the function:

Sub UpdateTableB()

  Dim sGetSQL As String
  On Error GoTo Duplicate_Error

  sGetSQL = "INSERT INTO tbl_B(caseID, fld_1, fld_2, fld_3, fld_4, etc ) " _
          & "SELECT Mid(someStringThatContainsCaseID, 58, 8), fld_1, fld_2, fld_3, fld_4 " _
          & "FROM tbl_A " _
          & "WHERE fld_4 IS NOT NULL"
         
  CurrentDb.Execute sGetSQL, dbFailOnError

Duplicate_Exit:
  Exit Sub
 
Duplicate_Error:
  Select Case Err.Number
    Case 3022
    MsgBox "The case already exists. Do you still want to proceed?"
  End Select
 
GoTo Duplicate_Exit
 
End Sub


Can anyone help me to modify the codes so as to achieve my objectives?

Thank you very much!
 Start Free Trial
Related Solutions: How to get OK OnClick?
[+][-]06.08.2008 at 10:48PM PDT, ID: 21741184

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.08.2008 at 11:28PM PDT, ID: 21741298

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.08.2008 at 11:38PM PDT, ID: 21741324

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 12:24AM PDT, ID: 21741463

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 12:44AM PDT, ID: 21741540

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 01:15AM PDT, ID: 21741644

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 01:25AM PDT, ID: 21741675

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 02:08AM PDT, ID: 21741813

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 03:01AM PDT, ID: 21741968

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 06:22PM PDT, ID: 21747842

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 07:39PM PDT, ID: 21748120

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Visual Basic Programming, SQL Query Syntax
Tags: MS Access, VBA
Sign Up Now!
Solution Provided By: game-master
Participating Experts: 3
Solution Grade: A
 
 
[+][-]06.09.2008 at 08:28PM PDT, ID: 21748274

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.09.2008 at 11:51PM PDT, ID: 21748950

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628