Solved

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

Posted on 2010-08-15
7
494 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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