Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2010-08-15
7
Medium Priority
?
501 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
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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

572 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