Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with "Goto New Record" in a subform.

183 views
Skip to first unread message

Frank Martin

unread,
Mar 26, 2005, 8:09:12 PM3/26/05
to
I wonder what I'm doing wrong here:

The subform name is 'CreditorsSUB' and the data therein based on
'QryCreditorTrans'.

In the properties dialogue I have set the 'Data Entry' to 'Yes' but still
the form refuses to display a new blank record.

I've had to solve the problem by using the wizard to place a button on the
subform with the "GotoLast" option (there being no "GotoNew") and then
altering the code behind the wizard's button as follows:

***
Private Sub Command23_Click()
On Error GoTo Err_Command23_Click

DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acNext

Exit_Command23_Click:
Exit Sub

End Sub

***
And now when I press this button I get the desired result.

But this seems a round-about way of doing it, so can someone help me with a
better way? Regards Frank


Allen Browne

unread,
Mar 26, 2005, 11:54:36 PM3/26/05
to
Assuming the button is in the subform (which means that it has focus), this
should work:

If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If
If Not Me.NewRecord Then
RunCommand acCmdRecordsGotoNew
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Frank Martin" <pa...@colonel.com.au> wrote in message
news:e8ZGmlm...@TK2MSFTNGP15.phx.gbl...

Frank Martin

unread,
Mar 27, 2005, 6:48:02 PM3/27/05
to
Thanks, I have altered this so that the following code is activated on the
"on enter" property of the subform with:
"RunCommand acCmdRecordsGotoNew"

The subform in question is linked to a Combobox with the Child/Master
properties of the subform and this will give all the records for the name
selected in the combobox.

However if there are no records for a particular name I get an error message
"RunCommand acCmdRecordsGoToNew is not available now."

How can I get the new record in the subform even if there are no records in
it.

PS I have already set the DataEntry property for the subform datasheet to
'Yes' but this has no effect - is there some occasions when this will not
work?

"Allen Browne" <Allen...@SeeSig.Invalid> wrote in message
news:uOyyWkoM...@TK2MSFTNGP14.phx.gbl...

Allen Browne

unread,
Mar 27, 2005, 7:30:01 PM3/27/05
to
If the form's DataEntry property is set to Yes, no existing record will
appear, and you will initially see *only* the new record row (unless no new
record can be added, in which case the detail section will go completely
blank.)

If you have only the new record row, then I fail to see the point of trying
to move to the new record row, because you are already there. Is is possible
that you are seeing the Default Value entries in the contorls, and not
recognising that you are already at the new record row?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Frank Martin" <pa...@colonel.com.au> wrote in message

news:e4LhpeyM...@TK2MSFTNGP15.phx.gbl...

Frank Martin

unread,
Mar 28, 2005, 12:27:15 AM3/28/05
to
My point is that I cannot get the DataEntry propery to work for the table
when in a subform.

It works well when the form is accessed directly in the form-objects screen,
and fails completely when this table is within the subform.

This has never happened before.

I amtrying to circumvent this problem by using the "RunCommand
acCmdRecordsGoToNew" and similar codes, though I would rather not.

Regatds, Frank


"Allen Browne" <Allen...@SeeSig.Invalid> wrote in message

news:e4o7L1yM...@TK2MSFTNGP15.phx.gbl...

Allen Browne

unread,
Mar 28, 2005, 2:18:49 AM3/28/05
to
Okay: you want to display *no* existing records in the subform, except the
one(s) the user is entering while at the main record. Then when the main
form moves record, all records in the subform should be suppressed again?

Unusual request, but try turning the subform's DataEntry off again (since it
does not work as expected), and set its RecordSource to a query that returns
no records. Example:
SELECT Table1.* FROM Table1 WHERE (False);
Naturally this returns no records, so you are instantly taken to the new
record. If you enter a record stays visible until you move record. Is that
the behavior you wanted?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Frank Martin" <pa...@colonel.com.au> wrote in message

news:ukrGOa1M...@TK2MSFTNGP12.phx.gbl...

Frank Martin

unread,
Mar 29, 2005, 12:57:11 AM3/29/05
to
Thanks, but I need something for this and other forms, such as:

*****
Private Sub CreditorsSuppTxnsSUB_Enter()

If Me.NewRecord = True Then
Me.[CreditorsSuppTxnsSUB].[Form]![AddressesID].SetFocus
Else
DoCmd.RunCommand acCmdRecordsGoToNew
Me.[CreditorsSuppTxnsSUB].[Form]![AddressesID].SetFocus
End If
*******

but this dosn't work!

Can you see anything wrong with the above?
Regards.


End Sub


"Allen Browne" <Allen...@SeeSig.Invalid> wrote in message

news:uoBlnZ2M...@tk2msftngp13.phx.gbl...

Allen Browne

unread,
Mar 29, 2005, 2:24:25 AM3/29/05
to
Frank, your code tests whether the main form is at a new record.

Did you intend this:

Private Sub CreditorsSuppTxnsSUB_Enter()
Me.CreditorsSuppTxnsSUB.Form!AddressesID.SetFocus
If Not Me.CreditorsSuppTxnsSUB.Form.NewRecord Then
DoCmd.RunCommand acCmdRecordsGoToNew
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Frank Martin" <pa...@colonel.com.au> wrote in message

news:%23eHmgQC...@TK2MSFTNGP15.phx.gbl...

Frank Martin

unread,
Mar 29, 2005, 2:51:19 AM3/29/05
to
Yes, thank you very much; this works like a dream.
Regards, Frank


"Allen Browne" <Allen...@SeeSig.Invalid> wrote in message

news:OaqpcBDN...@TK2MSFTNGP09.phx.gbl...

0 new messages