473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Error 3012: no current record on CLOSE of a "read only" form

18
I am currently working on an existing MS Access 03 data base that has been working perfectly for years. I have been requested to provide the userS the option to select a viewing option on a form, i.e. open as read only -v- edit.

The form currently has error trapping code everywhere and works fine when the form is opened with (current code):
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm strFormName, acNormal, , , acFormEdit, acWindowNormal, strSQL3
However when the form is triggered to opened with (new code):
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm strFormName, acNormal, , , acFormReadOnly, acWindowNormal, strSQL3
I get the error code 3021 no current record upon the CLOSE of the form only. I have tried to debug this with no success. The 3021 error is triggered BEFORE any of the vb code is triggered. I have looked extensively for a solution and have yet to fine one.

Any help would be appreciated.
Apr 3 '14 #1
13 2707
jimatqsi
1,271 Expert 1GB
Sven,
When the error code pops ups, what happens if you hit control/break? You should get into debug mode at the error message. Once you find where the error message is, make sure it is followed by
Expand|Select|Wrap|Line Numbers
  1. Resume next
If not, add that line. Then step through the code with F8 after the error message and you'll see what line of code actually triggered the error.

Jim
Apr 4 '14 #2
swen
18
jimatqsi,
Using the "control/break" only takes me to debugging and engages the "on close" code, without any errors. I get the 3021 error BEFORE any VB code is ran.

Unfortunately this is NOT my database, I have been asked to update it. The builder did not provide a button control to close the form, so users have to use the forms control box "X" to close. Just out of curiosity, I built a button control for the users to use and removed the control box "X" close... I got the same error 3021 PRIOR to the close code running.

Any thoughts?
Apr 4 '14 #3
mcupito
294 256MB
Well when you close the form in order to open this new form, what is the code there? Is something being edited? A module being ran? A public function being called?

Also, is the first form editable where the error is being thrown? It seems like it's in edit mode. Perhaps, on the before update event of that form, put in something like

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If Me.Dirty Then
  3.   If MsgBox("This form is attempting to save something", vbOKCancel, "Save?") = vbCancel Then
  4.     Me.Undo
  5.   End If
  6. End If
  7. End Sub
At this point, maybe we can narrow down the issue.
Apr 4 '14 #4
swen
18
mcupito,
The same form is used, the change is how it is opened. Users where making unintended changes to data, thus the request to allow the user to make a selection to open the form as "read only"(View) or Edit. Based on the selection made, now an If statement runs the Docmd...acFormEdit (original) -v- acFormReadOnly.

The user has the option to open ALL records (over 40,000) or via search criteria. The record source is based on a query. ALL forms, including this one, have code to check for and trap any errors related to EOF and BOF, and if no record is found, a msg box appears informing the user and will not open the form.

Everything works great until the form is opened as “read only”, regardless if one record or 40 records are pulled. When the read only version is closed, the 3021 error occurs before any code runs.

Could this be a relationship issue with the tables? I think I read something, somewhere on it.
Apr 4 '14 #5
mcupito
294 256MB
So when the form is opened as ReadOnly, what are the users doing on the form?
Apr 4 '14 #6
swen
18
Several departments review the data, for whatever their job function needs, (customer inquiry, quality standards, employee review, etc…) Not my place to question. Errors with data had happened when the user inadvertently; click a button, start typing in a field, etc… Thus, the request to make a View (read only) option available.

With Read only, if multiple records are pulled, the user only has the ability to navigate from one record to the next. If only one record is pulled, navigation is not available. All other functions, (i.e. edit, add, delete), are not available and the creation of yet another form and more code is not needed.
Apr 4 '14 #7
mcupito
294 256MB
And the Read Only form is the one that is throwing the error: 3021. Is there a SubForm involved at any point?

Worst comes to worst, you can comment out the Error Handleror throw the exception
Expand|Select|Wrap|Line Numbers
  1. (pseudo-code)
  2. If Err.Number <> 3021 
Especially if nothing disruptive is coming of it, and it's just an annoyance.
Apr 4 '14 #8
swen
18
Yes. Only the "Read Only" has the issue.
Yes. There is one SubForm

All forms already have error handling that include the: If Err.Number <> 3021 and EOF/BOF language.

The strange part is the 3021 error comes up BEFORE any VB code is ran. I have debugged everything and nothing errors via code.
Apr 4 '14 #9
zmbd
5,501 Expert Mod 4TB
OK, STOP! We're chasing our tails here without a clue as to where the true issue is:

SWEN:
Please post your code.
Both the ORIGINAL code and your changed code.
Please, click on the [CODE/] button in the post toolbar and then cut and paste your script between the [code] [/code] tags.
Apr 7 '14 #10
swen
18
Zmbd

As you requested

I get the error code 3021 (no current record) upon the CLOSE of the “READ ONLY” version of the form only. I get the error BEFORE the "on close" code is ran.

The ONLY code that has been changed is how the form is opened. The form itself does not have any changes. Its code already has code to trap for 3021 and EOF/BOF. Again, I get the error BEFORE code is ran when the "READ ONLY" version is closed.


Code 1. (ORIGIONAL)
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm strFormName, acNormal, , , acFormEdit, acWindowNormal, strSQL3

CHANGED TO:
Code 2

Expand|Select|Wrap|Line Numbers
  1. If Me.FrameA = 1 Then   'EDITABLE (UNCHANGED CODE)
  2.     DoCmd.OpenForm strFormName, acNormal, , , acFormEdit, acWindowNormal, strSQL3
  3. Else   'NONeditable (VIEW ONLY, READ ONLY)
  4.     DoCmd.OpenForm strFormName, acNormal, , , acFormReadOnly, acWindowNormal, strSQL3  
  5. End If
Apr 8 '14 #11
zmbd
5,501 Expert Mod 4TB
You need to review the entire original code.
More than likely, there is a focus or a new record being set or some other code that is forcing the issue.

Look at the events for on open, on load, current, on close, on unload, etc...
Apr 8 '14 #12
swen
18
Sorry for taking so long to get back on this. I have reviewed all the code and ALL is good. Everything is working fine now.

Our Network folks recently informed me they were changing settings (and various other things) on the servers during the time I was working on this. Does anyone else “enjoy” it when server work is being done and no one bothers to inform you?

I placed a "Close" button on the form with additional trapping code just in case this happens again.

I want to thank everyone for all your help.
Apr 18 '14 #13
zmbd
5,501 Expert Mod 4TB
Does anyone else “enjoy” it when server work is being done and no one bothers to inform you?
... about like having dental work without the anesthetic.

Thank you for taking the time to get back to us with the final resolution!

(^_^)
Apr 18 '14 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Richard Coutts | last post by:
I have a Continuous Form where each record has a button that activates another form that simplifies entering values into the record. The activated form has the equivalent of a "Done" button. I'd...
3
by: hebandgene | last post by:
When I delete a record in a subform I get the warning that I'm about to delete a record, followed by an error "No current record." When I click OK obviously the record is deleted and it goes to...
1
by: simonmarkjones | last post by:
Hi can someone please help me with a query. I would like to view only the current record with a query so i can create a report to be used as a customer receipt. How can i do this? Many...
1
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset and current record. I can do the recordset set...
2
by: SJ1000 | last post by:
Hi, I think I have a simple question that I just can't figure out. I want to have a command button on a form (via a macro) run a query to append the data on that form to another table.I want it to...
1
by: THEAF | last post by:
i'm trying to create a reminder form, when i add a new reminder its ok but when i try to delete a reminder then i get No Current Record problem. Form Load Private Sub Form_Load() Dim s() As...
5
by: Jamen98 | last post by:
I'm running into a problem with running multiple queries. I have two tables that look like: Risk_Mgmt_Table Fields: (Values) Filing_State: (CA) Membership: (Yes) Membership_Rate: (.95)...
0
by: Mauno Ahonen | last post by:
Hi. I'm having trouble exporting the current record displayed on a form to a PDF file. Please keep in mind that I'm a complete newb when it comes to Access and VBA. This is what I've come up with...
5
by: Redbeard | last post by:
I am working with Access 2007. I am trying to print a report from the current record on a Subform. My form is comprised of a Main form with a sub-form and another sub-form with in the sub-form. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.