Open form and display a blank record

F

freedomverse

I have a form with a button that has the following code:

Private Sub New_Story_Button_Click()

DoCmd.OpenForm "Story", , , , , acDialog
Me.Stories_Detail.Form.Story.Requery

End Sub

The button opens the "Story" form -- if I want the "Story" form to display a
new, blank record when it opens what is the best way to go accomplish this?

Regards,
jared.
 
F

fredg

I have a form with a button that has the following code:

Private Sub New_Story_Button_Click()

DoCmd.OpenForm "Story", , , , , acDialog
Me.Stories_Detail.Form.Story.Requery

End Sub

The button opens the "Story" form -- if I want the "Story" form to display a
new, blank record when it opens what is the best way to go accomplish this?

Regards,
jared.

DoCmd.OpenForm "Story", , , , acFormAdd, acDialog
 
F

freedomverse

that is close but I also want to see the other records in the split
datasheet. Any other ways?
 
F

fredg

that is close but I also want to see the other records in the split
datasheet. Any other ways?

You will find it helpful, when asking for assistance, if you give all
of the information needed the first time.

DoCmd.OpenForm "Story", , , , , acDialog,"GoToNew"

Code the "Story" form's Load event:

If Me.OpenArgs = "GoToNew" Then
DoCmd.RunCommand acCmdRecordsGoToNew
End If

The above will open the form "Story" in Dialog at a new record, but
you will have the ability to then scroll existing records.
 
F

freedomverse

Thank you very much!

Just for the sake of learning something new I have one more question. Is
there any reason not to put the code that you mentioned

DoCmd.RunCommand acCmdRecordsGoToNew

in the load event of the form that I want to open? Is it just another way
to skin a cat or is there a proper way to do this?

Thank you for all your help,
Jared.
 
F

fredg

Thank you very much!

Just for the sake of learning something new I have one more question. Is
there any reason not to put the code that you mentioned

DoCmd.RunCommand acCmdRecordsGoToNew

in the load event of the form that I want to open? Is it just another way
to skin a cat or is there a proper way to do this?

Thank you for all your help,
Jared.

Please include the relevant portion of any previous message in your
new messages, as I have with my replies to you. You may remember what
the previous message was about because it pertained to you. I
certainly don't remember your previous messages, therefore I have to
spend unnecessary time searching for them. It also makes this current
question understandable to others who may also benefit from the reply.
It's just a common courtesy.

So that others can follow this post, your other posts indicated you
wish to open a form, using code, at a new record entry, yet still
allow the user to scroll existing records.
Here is the relevant portion of my reply to that previous message.
*************
DoCmd.OpenForm "Story", , , , , acDialog,"GoToNew"

Code the "Story" form's Load event:

If Me.OpenArgs = "GoToNew" Then
DoCmd.RunCommand acCmdRecordsGoToNew
End If

The above will open the form "Story" in Dialog at a new record, but
you will have the ability to then scroll existing records.
*************

I don't understand your question here.
The RunCommand ** IS ** placed in the "Story" form's Load event.
It's wrapped inside the If Me.OpenArgs = .... End If statement so that
ONLY if the OpenArgs = "GoToNew" will the form open to a new record.

If you open the "Story" form from a different form or directly from
the application it will open to the first record, not a new record.

If always want it to open to a new record, and still allow scrolling
old records, then all you need is the RunCommand statment (without the
If.. End If), and there is no need for any OpenArgs at all.
 

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