Trouble opening to blank form

T

tdp

Hi--I have read the posts on this subsection and the Forms subsection about
trouble opening a data entry form to a new blank record while still allowing
users to navigate to and edit the existing records, but am still wondering if
anyone can help me.

I have a form with a subform. In the "On Open" event of the form, I have:

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRecord
End Sub

Allow Additions, Allow Deletions, Allow Edits are all set to Yes.

Data from the form populates an underlying table.

When I open the form, I get the error "Run-time error '2105': You can't go
to the specified record."

Why not???

Thanks for any help,
tdp
 
S

Stuart McCall

tdp said:
Hi--I have read the posts on this subsection and the Forms subsection
about
trouble opening a data entry form to a new blank record while still
allowing
users to navigate to and edit the existing records, but am still wondering
if
anyone can help me.

I have a form with a subform. In the "On Open" event of the form, I have:

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRecord
End Sub

Allow Additions, Allow Deletions, Allow Edits are all set to Yes.

Data from the form populates an underlying table.

When I open the form, I get the error "Run-time error '2105': You can't go
to the specified record."

Why not???

Thanks for any help,
tdp

At the time Form_Open runs, the controls are not yet initialized. Try moving
your code to Form_Load instead.
 
T

tdp

Stuart McCall said:
At the time Form_Open runs, the controls are not yet initialized. Try moving
your code to Form_Load instead.
I guess I should have said that I already tried that. I just tried the code
in Form_Load again (after deleting the open event) and got the same error
message.

tdp
 
J

John W. Vinson

Hi--I have read the posts on this subsection and the Forms subsection about
trouble opening a data entry form to a new blank record while still allowing
users to navigate to and edit the existing records, but am still wondering if
anyone can help me.

I have a form with a subform. In the "On Open" event of the form, I have:

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRecord
End Sub

Allow Additions, Allow Deletions, Allow Edits are all set to Yes.

Data from the form populates an underlying table.

When I open the form, I get the error "Run-time error '2105': You can't go
to the specified record."

Why not???

Thanks for any help,
tdp

Try using the Subform's Activate event instead.
 
D

Douglas J. Steele

tdp said:
I guess I should have said that I already tried that. I just tried the
code
in Form_Load again (after deleting the open event) and got the same error
message.


Is the form's RecordSource updatable?
 
T

tdp

John W. Vinson said:
Try using the Subform's Activate event instead.
I tried that--the main form still opens with the first record showing, not
as a blank form. If I double-click on the subform in the Objects window, I
get the same 2105 error message-You can't go to the specified record.

tdp
 
T

tdp

No--I want the main form to open to a blank record (and the subform as well).
I only tried to put the event procedure in (Sub)form_Activate because John
Vinson (above) suggested it.

tdp
 
T

tdp

No, the Recordset Type is Dynaset.

BTW, I am doing this in Access 2007, but the file type is .mdb because it
has to be compatible with Access at work, which is 2003. I doubt that makes a
difference.

This is driving me crazy because if I set the form to Data Entry, we can't
use the form to go back and look at or edit existing records, correct? That
is a problem.

tdp
 
T

tdp

Also, just for kicks I made a copy of the form, deleted the subform, and put
the required event procedure in Form_Load of the main form. Still got the
2105 error even without the subform.

tdp
 
G

Gina Whipp

TDP,

I don't see John's post... must be lost in Microsoft Post Heaven, anyway...

Please copy paste all the code behind this form (not the subform) here.
There must be something else preventing this from happening.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
J

John W. Vinson

No--I want the main form to open to a blank record (and the subform as well).
I only tried to put the event procedure in (Sub)form_Activate because John
Vinson (above) suggested it.

On reconsideration the Load event is in fact appropriate! It works for me, on
either a mainform or a subform. As Gina suggests... post your code. There's
something else going on.

Do note that when a Form with a Subform is opened, the subform (or subforms)
open first, then the main form.
 
T

tdp

All the code for the main form is as follows:

Option Compare Database

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRecord
End Sub


That is the only event procedure. Would there be code anywhere else?

BTW, thanks a lot to all of you who are trying to help...much appreciated!!

tdp
 
G

Gina Whipp

TDP,

Another thought... Please rem out the line or remove it and open the form
with the subform. Does anything on either one of those forms those #NAME?
in the field? Are the fields bound or unbound? Also, check the record
source of your combo box on your Main form. OR are you already at the last

I also noticed you have DoCmd.GoToRecord , , acNewRecord and I have
DoCmd.GoToRecord , , acNewRec However, seems to me you should be getting
another error if it didn't like yours.

And yet another thought... those two tables you are using for form/subform
are they a one-to-many relationship?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
T

tdp

There are no event procedures for any events on the subform, unless code
would be listed somewhere else besides the "event" tab on the subform's
property sheet.
 
T

tdp

There are no event procedures for any of the events on the "event" tab of the
properties sheet of the subform. Also, I copied the form and deleted the
subform to see if it made any difference. I tried the code

Option Compare Database

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRecord
End Sub

In each of the Load and Open events of the main form (not both at once,
obviously) without the subform and still got the 2105 error.
 
G

Gina Whipp

Try...

Another thought... Please rem out the line or remove it and open the form
with the subform. Does anything on either one of those forms those #NAME?
in the field? Are the fields bound or unbound? Also, check the record
source of your combo box on your Main form. OR are you already at the last

I also noticed you have DoCmd.GoToRecord , , acNewRecord and I have
DoCmd.GoToRecord , , acNewRec However, seems to me you should be getting
another error if it didn't like yours.

And yet another thought... those two tables you are using for form/subform
are they a one-to-many relationship?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 

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

Top