• Error Message (Access 97)

    Author
    Topic
    #357551

    I have a form where the primary key is the persons initials and a date. Only one record per initial on a specific date. If someone tries to enter another record with the same initials and date, they get an error message that reads, “You can’t go to the specified record. You may be at the end of a record set. ” I would like the error message to be more user friendly like, ” Record for those initials and date already entered.” I think I would want to put code in the After Update event of the form. How would I code this??

    Also, is there anyway to bring up the record that they are trying to duplicate?

    Viewing 0 reply threads
    Author
    Replies
    • #531360

      When you say “someone tries to enter another record with the same initials and date”, exactly what is the situation? The error message you are getting seems to indicate you are in a Find situation (not actually adding a new record yet). If you were trying to add a new record, then the Form’s BeforeUpdate event would be the place to test for the existenance of a record with same initials and date. (and unless you have about 3 people in your database, using initials as a unique identifer is not a good idea in the long run.)

      • #531361

        The form is set up for data entry. There are only 8 people using the form to enter what they did for the week. They enter their initials and monday’s date of the week they are reporting for and then they enter the data into the fields that apply to them and click on Add Record . Sometimes they enter their initials and the same date again and try to enter another record. Thats when they get that error message.

        • #531386

          Well, it’s still an odd message, given the circumstances. But anyway, in the code for Add Record (apparently they’ve already entered their initials and date, and click Add Record to actually save info), you need to do a DLookup to see if a record exits with same initials and date. If it does, then Exit Sub immediately.

          • #531396

            You could always put a message box in the error trapping of the before update event of the form that said,

            if msgbox(“You have had an error trying to save this record. Perhaps you’ve already entered your report for this day. Would you like to search for your entry for today?”,vbyesno) = vbyes then
            docmd.runcommand accmdfilterbyform
            docmd.runcommand accmdcleargrid
            end if

            This would prompt them with a yes/no question. If they answer yes then they will go into a filter by form so that they could look up their entry for that day. If you wanted to, you could also include some code to copy the “comments section” of the form so that they could hit CTRL V and paste the additional comments onto the end of the existing report.

            Jeff Dever

    Viewing 0 reply threads
    Reply To: Error Message (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: