Trying to get form to open blank

G

Guest

I tried this in my form that is for editing existing records only. I got
error 2046, Command RecordsGoToNew is not available at this time. What did I
do wrong?
 
J

James Goodman

You have explained it yourself. If the form is set to allow edits only, it
wont allow you to goto a new record! :)
 
G

Guest

Are you saying you used the code that was part of your posting? If so, you
used code to add a new record when your specific intention was to edit
existing records only. If you place the following into the form's Open event
(or Activate event, or whatever works for you) it will open the form to the
last record:
Docmd.GoToRecord, , acLast

acFirst will open the form to the first record.
 
A

Andi Mayer

I tried this in my form that is for editing existing records only. I got
error 2046, Command RecordsGoToNew is not available at this time. What did I
do wrong?

Nothing, the form doesn't allow to add records, access tells you that
you are not allowed to do this, if you add a new record.

Set the starting recordsource to a query that shows no-records, like
a: SELECT * From table WHERE 1=2

and after you choose something from the comboBox:

me.recordsource=SELECT * From table WHERE thisfield=me.combobox
If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
G

Guest

Nevermind, I got this to work. I had to change Allow Additions to Yes,
just hope no one uses it to add.
 
G

Guest

Thanks Andi, I will try this.

Andi Mayer said:
Nothing, the form doesn't allow to add records, access tells you that
you are not allowed to do this, if you add a new record.

Set the starting recordsource to a query that shows no-records, like
a: SELECT * From table WHERE 1=2

and after you choose something from the comboBox:

me.recordsource=SELECT * From table WHERE thisfield=me.combobox
If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 
V

Van T. Dinh

I am fairly Allen Browne's reply was in a different context.

If you want to open the Form for editing only, you want to set
AllowAdditions to False and don't use acCmdRecordsGoToNew.

--
HTH
Van T. Dinh
MVP (Access)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top