Data Entry mode does not work in subform.

F

Frank Martin

I have a subform "SuppTxnsSUB" based on the tblSuppTxns, and a particular
supplier's transactions are selected vis a plain combo box (no wizard) by
having the combo as the Master to the "SuppTxnsSUB"'s Child.

This works well.

My aim is to go to a new record in the subform for a combo-selected
supplier, and I hoped to do this by making the tblSuppTxns "DateEntry" set
to 'yes' in the properties.

But this does not seem to work when a table is expressed in a subform! Why?

To get around this I put some code behind the subform's "OnEnter" property
as follows:

" RunCommand acCmdRecordsGoToNew"

This works well if a supplier has previous transactions in the recordset,
but fails completely for a new supplier with no records as yet and this
gives an error
"unable to goto new".

How can I end up with the cursor in a new record in "SuppTxnsSUB" even if
there are records present or not?

Plesae help, Frank
 
A

Arvin Meyer

You can't go to a new record if you are already at one. There is a NewRecord
property of a form that you can check first (aircode):

Sub Form_Current()
If Me.NewRecord = True Then
Me.FirstControlName.SetFocus
Else
DoCmd.RunCommand acCmdRecordsGoToNew
Me.FirstControlName.SetFocus
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
F

Frank Martin

Thank you. I have tried this code (as several variations) to no avail.

The best I have come up with is:
*****
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

End Sub
********

which stubbornly refuses to work.

I wonder if you can give me some fresh ideas?
Regards.
 
A

Andreas

If Me.NewRecord = True
You are checking the mainform, rather than the subform.

Try something like (untested):
If Me.[CreditorsSuppTxnsSUB].[Form].NewRecord = True

Same goes for adding a new record.

Regards,
Andreas


Frank said:
Thank you. I have tried this code (as several variations) to no avail.

The best I have come up with is:
*****
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

End Sub
********

which stubbornly refuses to work.

I wonder if you can give me some fresh ideas?
Regards.



You can't go to a new record if you are already at one. There is a
NewRecord
property of a form that you can check first (aircode):

Sub Form_Current()
If Me.NewRecord = True Then
Me.FirstControlName.SetFocus
Else
DoCmd.RunCommand acCmdRecordsGoToNew
Me.FirstControlName.SetFocus
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
F

Frank Martin

Thanks, I have settled on:

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

*******
Which works rather well


Andreas said:
If Me.NewRecord = True
You are checking the mainform, rather than the subform.

Try something like (untested):
If Me.[CreditorsSuppTxnsSUB].[Form].NewRecord = True

Same goes for adding a new record.

Regards,
Andreas


Frank said:
Thank you. I have tried this code (as several variations) to no avail.

The best I have come up with is:
*****
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

End Sub
********

which stubbornly refuses to work.

I wonder if you can give me some fresh ideas?
Regards.



You can't go to a new record if you are already at one. There is a
NewRecord
property of a form that you can check first (aircode):

Sub Form_Current()
If Me.NewRecord = True Then
Me.FirstControlName.SetFocus
Else
DoCmd.RunCommand acCmdRecordsGoToNew
Me.FirstControlName.SetFocus
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access


I have a subform "SuppTxnsSUB" based on the tblSuppTxns, and a
particular
supplier's transactions are selected vis a plain combo box (no wizard)
by
having the combo as the Master to the "SuppTxnsSUB"'s Child.

This works well.

My aim is to go to a new record in the subform for a combo-selected
supplier, and I hoped to do this by making the tblSuppTxns "DateEntry"
set
to 'yes' in the properties.

But this does not seem to work when a table is expressed in a subform!

Why?

To get around this I put some code behind the subform's "OnEnter"
property
as follows:

" RunCommand acCmdRecordsGoToNew"

This works well if a supplier has previous transactions in the
recordset,
but fails completely for a new supplier with no records as yet and this
gives an error
"unable to goto new".

How can I end up with the cursor in a new record in "SuppTxnsSUB" even
if
there are records present or not?

Plesae help, Frank
 

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