Solved

HOW TO ELIMINATE ERROR MESSAGE WHEN CLICK EITHER “CLOSE, BACK OR NEXT”.

Posted on 2010-08-15
7
493 Views
Last Modified: 2013-11-28
PROBLEM CODE

Problem code on the BEFORE UPDATE EVENT ON FORM “frmAHA_VER1”


Sub Form_BeforeUpdate(Cancel As Integer)

If Nz(DLookup("AHATitle", "3-tblAHA_VER1", "AHATitle='" & Me.AHATitle & "'"), "") <> "" Then
  MsgBox "The AHA Title you entered is a duplicate. To continue, click the BACK BUTTON and enter a unique AHA Title. If you still have questions or problems please contact the CSSC office for support at: Phone: 630-566-9010 - Email: csscservice@comcast.net.", vbOKOnly
  Cancel = True
End If
End Sub


DESCRIPTION

Chnage or add any information to any of the FIELDS on either the "AHA Details tab" or the "Dirty Dozen tab" causes the message to be displayed.


RECREATE ERROR MESSAGE

1 LOG INTO APPLICATION
2. CLICK THE EDIT AHA BUTTON
3. SELECT ANY AHA
4. WHEN YOU GET TO THE FORM “frmAHA_VER1” edit, change or add information to any field on either tab. Then click either Close, Back or Next.
The error message will then display.


ErrorMessage-8-15-2010.jpg
TEST-8-15-2010-AHA-Builder-2010-.zip
0
Comment
Question by:cssc1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 10

Expert Comment

by:t_hungate
ID: 33442191
CSSC

I have looked at this a bit, and the form that is giving you this problem, is meant to update or edit, a  record that is currently in the recordset, correct?

If so you are issue is that your code is just looking to see if the title matches any title already in the table.  When that is found to be true you are presented the the error message.  The problem is, you are editing a record that you know to be in the table, and there for should not be running this IF.  

Now I think you may want to check and make sure that they have not changed the title while they were editing the form, and I would warn them that changing the title will cause them to loose any changes that were made, or something to that effect.  I would also, check to ensure that the title is not blank, before you allow them to proceed to the next form.

So long story short, you do not need this code here, as the title is being carried over form the first form, and you will get a true return on your IF statement every time.  I have commented it out and made some test edits to the data, and the forms all seem to work as they appear to be designed to.

TLH
0
 
LVL 20

Expert Comment

by:GrahamMandeno
ID: 33442260
If this is an existing record, then your DLookup will find the same record that you are editing.  You need to look for records with a matching title EXCLUDING the current record.
Does your table have a primary key?  Let's assume you have an autonumber PK named AHI_id.  You can then use this code:
If Nz(DLookup("AHATitle", "3-tblAHA_VER1", "AHATitle='" & Me.AHATitle & "'"), 0) <> Me.AHI_id Then
--
Graham
0
 
LVL 20

Assisted Solution

by:GrahamMandeno
GrahamMandeno earned 500 total points
ID: 33442263
Oops - sorry - copy/paste error...
If Nz(DLookup("AHA_id", "3-tblAHA_VER1", "AHATitle='" & Me.AHATitle & "'"), 0) <> Me.AHI_id Then
--
Graham
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:cssc1
ID: 33442517
GrahamMandeno:
  Code won't compile.
See attached image for error message
seeError-8-15-2010.jpg
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33443236
Make a note, this message means that it cannot find that Field or control.
So substitute it with the name of the field that actually holds this ID
0
 
LVL 20

Accepted Solution

by:
GrahamMandeno earned 500 total points
ID: 33444205
@cssc1:
Note that I said: <<Let's assume you have an autonumber PK named AHI_id.>>
Does your table have such a primary key field?  If not, then of course the code will not work.
Make sure that the field name in your code matches the name of the primary key in your table (note that it appears twice in that line) and also that it is included in the RecordSource of your form.
--
Graham
0
 

Author Closing Comment

by:cssc1
ID: 33444229
Thanks!
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question