Form and Subform

G

Guest

I have two quirky errors; don't know if they're related or not.

1 - have 'add record' button on form. when clicked, correct form opens, but
not to new record. I have to click * button to get to new record. Here's
code, pretty straightforward:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmContacts"
DoCmd.GoToRecord , , acNewRec

DoCmd.OpenForm stDocName, , , stLinkCriteria

2 - When in 'frmContacts' and adding new data to subform, subform appears to
jump to next new record when I try to tab (exit) out of the subform. Can
only see what I just input by exiting form and then coming back in again.

Thanks for your help.
Pat
 
R

Rick Brandt

pattylb said:
I have two quirky errors; don't know if they're related or not.

1 - have 'add record' button on form. when clicked, correct form
opens, but not to new record. I have to click * button to get to new
record. Here's code, pretty straightforward:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmContacts"
DoCmd.GoToRecord , , acNewRec

Here you are asking to go to a new record in the CURRENT form.
DoCmd.OpenForm stDocName, , , stLinkCriteria

Now you are opening the form where you want to enter a new record (see the
problem?)

The OpenForm method has an argument that will open the form in DataEntry
mode (at a new record).

DoCmd.OpenForm "FormName",,,,acFormAdd
 
G

Guest

Thanks for your help.

So my code was redundant? I'll have to play with it because I just don't
quite see it.

But your solution worked well, and it seems neater.

Thanks again.
 

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