Subform Rows

  • Thread starter injanib via AccessMonster.com
  • Start date
I

injanib via AccessMonster.com

In a subform which is in a continous mode, when first opened it only displays
one row. As soon as you enter a value in the first field, it displays the
second row and so on.

How can you make it to display the second next only after a particular field
is updated in the previous row?
 
D

Dirk Goldgar

injanib via AccessMonster.com said:
In a subform which is in a continous mode, when first opened it only
displays
one row. As soon as you enter a value in the first field, it displays the
second row and so on.

How can you make it to display the second next only after a particular
field
is updated in the previous row?


In the Current event of the subform, set its AllowAddtions property to False
if it's not on the new record:

'----- start of code for Current event -----
Private Sub Form_Current()

Me.AllowAdditions = Me.NewRecord

End Sub
'----- end of code for Current event -----

Then, in the AfterUpdate event of the designated control, set the
AllowAdditions property to True if your conditions are met. If you want to
have this happen only when the control is updated on the last record of the
subform, I think this would work:

'----- start of (untested) example code -----
Private Sub SomeControl_AfterUpdate()

If Not IsNull(Me.SomeControl) Then

If Me.CurrentRecord = Me.Recordset.RecordCount Then
Me.AllowAdditions = True
End If

End If

End Sub
'----- end of example code -----

Note that, if all you're trying to do here is make a particular field
required, there are simpler ways to do it.
 
I

injanib via AccessMonster.com

Thank you .

The reason I need this is because my subform has an auto number filed. when
the first row is dirty the second row is populated and the autonumber field
is assigned a number. Even if I don't need to enter in the second row, this
row gets saved and so it fills out my table with a bunch of blank rows.


Dirk said:
In a subform which is in a continous mode, when first opened it only
displays
[quoted text clipped - 4 lines]
field
is updated in the previous row?

In the Current event of the subform, set its AllowAddtions property to False
if it's not on the new record:

'----- start of code for Current event -----
Private Sub Form_Current()

Me.AllowAdditions = Me.NewRecord

End Sub
'----- end of code for Current event -----

Then, in the AfterUpdate event of the designated control, set the
AllowAdditions property to True if your conditions are met. If you want to
have this happen only when the control is updated on the last record of the
subform, I think this would work:

'----- start of (untested) example code -----
Private Sub SomeControl_AfterUpdate()

If Not IsNull(Me.SomeControl) Then

If Me.CurrentRecord = Me.Recordset.RecordCount Then
Me.AllowAdditions = True
End If

End If

End Sub
'----- end of example code -----

Note that, if all you're trying to do here is make a particular field
required, there are simpler ways to do it.
 
D

Dirk Goldgar

injanib via AccessMonster.com said:
Thank you .

The reason I need this is because my subform has an auto number filed.
when
the first row is dirty the second row is populated and the autonumber
field
is assigned a number. Even if I don't need to enter in the second row,
this
row gets saved and so it fills out my table with a bunch of blank rows.


That should *not* happen, unless you have code or a macro that is dirtying
the new record when it becomes current. Maybe you have code that assigns an
initial value to one of the fields.

Normally, the autonumber is not assigned to the new record until you make
some modification to the record.
 

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