Need blank form/subform - get runtime error

  • Thread starter Thread starter MonicaS
  • Start date Start date
M

MonicaS

Guest
I am working with Access 97. I have a combo box at the top of my form. Under the combo box, I have a form that contains a subform. When I choose an item from the combo box, the form and subform are populated with the information related to the item I choose. All of this works fine. Here is the problem: I want the form and subform to be completely blank when it is opened. If I set the Data Entry property to yes on the form and subform I get the following error:
Run-Time error 3021: No Current Record

When I click on the debug option it comes up with me.recordsetclone.bookmark=<No Current Record>

Why am I getting this and how do I resolve it?

Thank you
 
Your code is trying to allocate a book mark against a record that does not exist. Logically it can not do that so it fails.

You can alter your code to ignore the error if it fails. This is a fairly crude method but may be appropriate in some cases.

Or you could check for the new record and only process you bookmark code if required

if me.newrecord then

'Do nothing or any other procesing specific to a new record

else

'Your bookmark or other specific processing code here

endif

(Please check the help file for the newrecord syntax as I have done the above from memory)

Hope this helps
Trevor from www.accesswatch.co.uk
 
Yes, that helps me understand some of the problem, but not quite all of it. I still don't understand why it does it only when I set the Data Entry property to yes so that I can have a blank form. It says it can't find the specific record that I am looking for, but I know the record exists. Any other thoughts on how I can get a blank form if not setting the Data Entry property to yes?

Thank you again!
 
When you set the Data Entry Property to yes you are telling Access to 'Put me in a position so that I can start to create a new Record' At this point the Record does not exist.
Because the record does not exist it cannot have a bookmark because bookmarks can only be allocated to records that exist.Because the bookmark does not exisit you cannot set a pointer to the bookmark i.e you cannot point to something that does not exist (Although a Zen buddist may argue this point)

When you are in Data Entry mode your form does not have access to the other records, it is simply placed in the position to start accepting new data.


If you want to open the form ready for data entry then you will need to make sure your Combo box is set to enabled = false. This will prevent the user from clicking on the Combo box which would generate a error. Also alter your code so that it does not try to allocate the bookmark.

It can sometimes be a bit confusing when using a common form to do both Data Entry and Data Editing because the state of the underlying records differ. i.e In data edit mode the underlying record DOES exist and at least one field has been initialised (i.e has a value of not NULL) therefore you can edit it, in data Entry mode the record DOES NOT exist until you have entered some data (i.e changed the state of at least one field from NULL) and updated the database to accept the new record.

A common technique is to use different forms for Data Entry and For Data Editing. If you want to use a common form for both Data Entry and Data Editing then you must ensure that the properties that apply to Data Edit but which are not applicable to Data Entry are all 'switched off'. You will then have to switch them back on again when you switch back to Data Edit mode.
Simplist way to remember it is
you can only do 3 basic things with records

Add a new record (Data Entry)
Edit A record (Data editing)
Delete a record

Applying this to your question:
You can have a 'blank' form which
1-Is unbound and cannot accept any data until it is bound (not much use)
2-A form awaiting Data Entry. In this state the form exists but it has no underlying record
3-A form where at least one field has its state changed from NOT NULL to "" (Blank)

So if you want a form to open and Appear blank you need to ensure that a least one field is set to not Null. You can do this in a number of ways. The easiest is to set a default value for one of the forms fields, if you want it to appear blank then set the value to "". Or you could assign the "" value in code during the forms OnOpen event.

Once you have changed the state of one of the forms underlying fields from NULL and you have saved the record then Access will allocate a bookmark to the record.

Sorry if you know most of this but it may be of use to others. Also I hope it helps to explain a common problems some people have in understanding the difference between BLANK and NULL.
Fields with a value of NULL are uninitialised fields (i.e have no value).
BLANK fields are fields containing a zero length string (have a value of zero length string)
Forms opened in Data Entry Mode have all the fields set to NULL
Forms opened with at least one record set to not Null, even if that field is "" (blank", are in a different state to the Data Entry form even if they look the same

Hope This helps
Regards
Trevor from www.accesswatch.co.uk




[This message has been edited by accesswatch (edited 10-06-2000).]
 
Last edited:
This is a belated thank you.....Thank you so much for your time! Everything you wrote helped us!
 

Users who are viewing this thread

Back
Top Bottom