Continuous subform - how to make it appear differently for new rec

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a continuous subform which can be put into Allow Additions=True by a
button on the main form.

I also have a delete button which appears next to each record in the subform
(ie this is in the detail section of the subform) How can I set this delete
button to only appear next to existing records (ie not appear next to the
new, blank record which is waiting for data input?) There are 4 required
fields and I would like the delete button to appear anly when they are
complete (ie when the new record is complete and is saved and thus exists in
the table [do I need something in the before update event?]

Looking forward to your thoughts
Rich
 
You could hide or disable the button in the form's Current event if you are
at a new record:
Private Sub Form_Current()
Me.cmdDelete.Enabled = Not Me.NewRecord
End Sub

You probably want to enable it in Form_AfterInsert.

Alternatively, you could just change the code behind the button so that it
just undoes the new record:
Private Sub cmdDelete_Click()
If Me.Dirty Then Me.Undo
If Not Me.NewRecord Then RunCommand acCmdDeleteRecord
End Sub
 
Hi Allen

I tried both of your suggestions. Nice lateral thinking! I forgot to tell
you about an input mask I have on one of the fields. Here are my results:

The problem with the first suggestion is that it makes all of the delete
buttons in the subform "grey out" - not just the button on the current record.
The problem with the second suggestion is that I have an input mask on the
field button that requires 8 characters are input. So if less characters are
input and the form "undoes," I get an error (no 2279) - input mask violated I
think (although I've customised this message.) Is there a way I can check
the field length and if it is 8 characters long, then display the delete
button for that record (whilst leaving all other delete buttons showing all
of the time?)

Is this possible in a continuous subform or is the "delete button" always
the same in all the records on the form - ie if you change the definition,
does the button change on all records of the form simultaneously?

Thanks Allen
Rich
Allen Browne said:
You could hide or disable the button in the form's Current event if you are
at a new record:
Private Sub Form_Current()
Me.cmdDelete.Enabled = Not Me.NewRecord
End Sub

You probably want to enable it in Form_AfterInsert.

Alternatively, you could just change the code behind the button so that it
just undoes the new record:
Private Sub cmdDelete_Click()
If Me.Dirty Then Me.Undo
If Not Me.NewRecord Then RunCommand acCmdDeleteRecord
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rich1234 said:
I have a continuous subform which can be put into Allow Additions=True by
a
button on the main form.

I also have a delete button which appears next to each record in the
subform
(ie this is in the detail section of the subform) How can I set this
delete
button to only appear next to existing records (ie not appear next to the
new, blank record which is waiting for data input?) There are 4 required
fields and I would like the delete button to appear anly when they are
complete (ie when the new record is complete and is saved and thus exists
in
the table [do I need something in the before update event?]

Looking forward to your thoughts
Rich
 
It is not possible to set the Enabled property of one control on a
continuous form differently than other rows.

You use Len() in the Change event of the control to see if its Text property
is 8 characters long.

Yes, input masks are generally more of a hindrance than anything else.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rich1234 said:
I tried both of your suggestions. Nice lateral thinking! I forgot to
tell
you about an input mask I have on one of the fields. Here are my results:

The problem with the first suggestion is that it makes all of the delete
buttons in the subform "grey out" - not just the button on the current
record.
The problem with the second suggestion is that I have an input mask on the
field button that requires 8 characters are input. So if less characters
are
input and the form "undoes," I get an error (no 2279) - input mask
violated I
think (although I've customised this message.) Is there a way I can check
the field length and if it is 8 characters long, then display the delete
button for that record (whilst leaving all other delete buttons showing
all
of the time?)

Is this possible in a continuous subform or is the "delete button" always
the same in all the records on the form - ie if you change the definition,
does the button change on all records of the form simultaneously?

Thanks Allen
Rich
Allen Browne said:
You could hide or disable the button in the form's Current event if you
are
at a new record:
Private Sub Form_Current()
Me.cmdDelete.Enabled = Not Me.NewRecord
End Sub

You probably want to enable it in Form_AfterInsert.

Alternatively, you could just change the code behind the button so that
it
just undoes the new record:
Private Sub cmdDelete_Click()
If Me.Dirty Then Me.Undo
If Not Me.NewRecord Then RunCommand acCmdDeleteRecord
End Sub

Rich1234 said:
I have a continuous subform which can be put into Allow Additions=True
by
a
button on the main form.

I also have a delete button which appears next to each record in the
subform
(ie this is in the detail section of the subform) How can I set this
delete
button to only appear next to existing records (ie not appear next to
the
new, blank record which is waiting for data input?) There are 4
required
fields and I would like the delete button to appear anly when they are
complete (ie when the new record is complete and is saved and thus
exists
in
the table [do I need something in the before update event?]

Looking forward to your thoughts
Rich
 
ok Allen. Thanks for the tips

Allen Browne said:
It is not possible to set the Enabled property of one control on a
continuous form differently than other rows.

You use Len() in the Change event of the control to see if its Text property
is 8 characters long.

Yes, input masks are generally more of a hindrance than anything else.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rich1234 said:
I tried both of your suggestions. Nice lateral thinking! I forgot to
tell
you about an input mask I have on one of the fields. Here are my results:

The problem with the first suggestion is that it makes all of the delete
buttons in the subform "grey out" - not just the button on the current
record.
The problem with the second suggestion is that I have an input mask on the
field button that requires 8 characters are input. So if less characters
are
input and the form "undoes," I get an error (no 2279) - input mask
violated I
think (although I've customised this message.) Is there a way I can check
the field length and if it is 8 characters long, then display the delete
button for that record (whilst leaving all other delete buttons showing
all
of the time?)

Is this possible in a continuous subform or is the "delete button" always
the same in all the records on the form - ie if you change the definition,
does the button change on all records of the form simultaneously?

Thanks Allen
Rich
Allen Browne said:
You could hide or disable the button in the form's Current event if you
are
at a new record:
Private Sub Form_Current()
Me.cmdDelete.Enabled = Not Me.NewRecord
End Sub

You probably want to enable it in Form_AfterInsert.

Alternatively, you could just change the code behind the button so that
it
just undoes the new record:
Private Sub cmdDelete_Click()
If Me.Dirty Then Me.Undo
If Not Me.NewRecord Then RunCommand acCmdDeleteRecord
End Sub


I have a continuous subform which can be put into Allow Additions=True
by
a
button on the main form.

I also have a delete button which appears next to each record in the
subform
(ie this is in the detail section of the subform) How can I set this
delete
button to only appear next to existing records (ie not appear next to
the
new, blank record which is waiting for data input?) There are 4
required
fields and I would like the delete button to appear anly when they are
complete (ie when the new record is complete and is saved and thus
exists
in
the table [do I need something in the before update event?]

Looking forward to your thoughts
Rich
 
Hi Allen,
CF supports the Enabled property for a TextBox control for a form in
Continuous view.

The OP basically requested that the Visible prop be exposed via CF but this
is not supported. You can fake the resultant UI but I personally do not
reccommend this solution.
Sample code is here:
http://www.lebans.com/conditionalformatting.htm
New Feb 08,2002. Added support for Datasheet view and SubForms.

A2KConditionalFormatting.zip is a sample MDB demonstrating how to
programmatically setup Conditional Formatting to simulate:

1) Highlighting of the Current Row for a Form in Continuous or Datasheet
View

2) Highlighting of Alternate Rows for a Form in Continuous or Datasheet View

Version 2.7

Added sample demonstrating how to achieve a background Hover/Highlighting of
rows for a form in Continuous view.

Version 2.3

Added sample demonstrating how to achieve pseudo enable/disable of an
unbound control on a form in Continuous View.

Version 1.9

Added sample form to show how to apply conditional formatting to based on a
Boolean(Yes/No) field.

Verrsion 1.8

Starting to cleanup code and add comments!

Version 1.4

First release


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
Allen Browne said:
It is not possible to set the Enabled property of one control on a
continuous form differently than other rows.

You use Len() in the Change event of the control to see if its Text
property is 8 characters long.

Yes, input masks are generally more of a hindrance than anything else.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rich1234 said:
I tried both of your suggestions. Nice lateral thinking! I forgot to
tell
you about an input mask I have on one of the fields. Here are my
results:

The problem with the first suggestion is that it makes all of the delete
buttons in the subform "grey out" - not just the button on the current
record.
The problem with the second suggestion is that I have an input mask on
the
field button that requires 8 characters are input. So if less characters
are
input and the form "undoes," I get an error (no 2279) - input mask
violated I
think (although I've customised this message.) Is there a way I can
check
the field length and if it is 8 characters long, then display the delete
button for that record (whilst leaving all other delete buttons showing
all
of the time?)

Is this possible in a continuous subform or is the "delete button" always
the same in all the records on the form - ie if you change the
definition,
does the button change on all records of the form simultaneously?

Thanks Allen
Rich
Allen Browne said:
You could hide or disable the button in the form's Current event if you
are
at a new record:
Private Sub Form_Current()
Me.cmdDelete.Enabled = Not Me.NewRecord
End Sub

You probably want to enable it in Form_AfterInsert.

Alternatively, you could just change the code behind the button so that
it
just undoes the new record:
Private Sub cmdDelete_Click()
If Me.Dirty Then Me.Undo
If Not Me.NewRecord Then RunCommand acCmdDeleteRecord
End Sub


I have a continuous subform which can be put into Allow Additions=True
by
a
button on the main form.

I also have a delete button which appears next to each record in the
subform
(ie this is in the detail section of the subform) How can I set this
delete
button to only appear next to existing records (ie not appear next to
the
new, blank record which is waiting for data input?) There are 4
required
fields and I would like the delete button to appear anly when they are
complete (ie when the new record is complete and is saved and thus
exists
in
the table [do I need something in the before update event?]

Looking forward to your thoughts
Rich
 
Back
Top