subforms record navigation

R

Russ

I've got 2 subforms on another form. Each one of them is displaying
the same data from a query. I am using two subforms so I can see
adjacent records in a table, and then do some math calculations with
them. Can I manipulate these sub-forms somehow so that when I advance
or go back one record on one of them, the other sub-form will also
advance/go back one record?

I would like to keep them always separated so I see different adjacent
records. This is being done to calculate water payments for a rural
water district.

Russ
Access 2000
 
D

David Cleave

Russ

I tried to solve this problem using the AbsolutePosition property of the
recordsets for the subforms. You can access the AbsolutePosition like this:

[Forms]![Form Name]![Subform Name].Form.Recordset.AbsolutePosition

There are two things you need to do:

1) When you change record in subform 1, change the record in subform 2 to
the one after the record in subform 1.
2) When subform 2 loads for the first time, change its record to be the one
after the record in subform 1.

You also need to deal with BOF and EOF situations, but I didn't bother at
this stage. (I.E. what does subform 2 display if subform 1 is showing the
last record?)

In the On Current event for subform 1 I put this:
On Error Resume Next
[Forms]![The Form]![Subform 2].Form.Recordset.AbsolutePosition =
Me.Recordset.AbsolutePosition + 1

On Error Resume Next is necessary, because subform 1 loads before subform 2,
and tries to refer to subform 2 before it has loaded, causing a runtime error.

In the On Load event for subform 2 I put this:

Me.Recordset.AbsolutePosition = [Forms]![Delete This Form]![Delete This Form
First subform].Form.Recordset.AbsolutePosition + 1

This generates an error saying the argument is of the wrong type. Given that
the syntax is identical to the code in the other subform, I am stumped as to
why.

Anyone else got any good ideas???

David
 
R

Russ

Dave,

I can answer one of the questions that you asked. When subform 1 is
at the last record, subform 2 should show a new record. That way a
new water reading can be entered.

Russ

Russ

I tried to solve this problem using the AbsolutePosition property of the
recordsets for the subforms. You can access the AbsolutePosition like this:

[Forms]![Form Name]![Subform Name].Form.Recordset.AbsolutePosition

There are two things you need to do:

1) When you change record in subform 1, change the record in subform 2 to
the one after the record in subform 1.
2) When subform 2 loads for the first time, change its record to be the one
after the record in subform 1.

You also need to deal with BOF and EOF situations, but I didn't bother at
this stage. (I.E. what does subform 2 display if subform 1 is showing the
last record?)

In the On Current event for subform 1 I put this:
On Error Resume Next
[Forms]![The Form]![Subform 2].Form.Recordset.AbsolutePosition =
Me.Recordset.AbsolutePosition + 1

On Error Resume Next is necessary, because subform 1 loads before subform 2,
and tries to refer to subform 2 before it has loaded, causing a runtime error.

In the On Load event for subform 2 I put this:

Me.Recordset.AbsolutePosition = [Forms]![Delete This Form]![Delete This Form
First subform].Form.Recordset.AbsolutePosition + 1

This generates an error saying the argument is of the wrong type. Given that
the syntax is identical to the code in the other subform, I am stumped as to
why.

Anyone else got any good ideas???

David

Russ said:
I've got 2 subforms on another form. Each one of them is displaying
the same data from a query. I am using two subforms so I can see
adjacent records in a table, and then do some math calculations with
them. Can I manipulate these sub-forms somehow so that when I advance
or go back one record on one of them, the other sub-form will also
advance/go back one record?

I would like to keep them always separated so I see different adjacent
records. This is being done to calculate water payments for a rural
water district.

Russ
Access 2000
 
D

David Cleave

Hi Russ

I got as far as I could do with this one I'm afraid. I just couldn't find a
way around that error. You could try to repost I guess.

Cheers

David

Russ said:
Dave,

I can answer one of the questions that you asked. When subform 1 is
at the last record, subform 2 should show a new record. That way a
new water reading can be entered.

Russ

Russ

I tried to solve this problem using the AbsolutePosition property of the
recordsets for the subforms. You can access the AbsolutePosition like this:

[Forms]![Form Name]![Subform Name].Form.Recordset.AbsolutePosition

There are two things you need to do:

1) When you change record in subform 1, change the record in subform 2 to
the one after the record in subform 1.
2) When subform 2 loads for the first time, change its record to be the one
after the record in subform 1.

You also need to deal with BOF and EOF situations, but I didn't bother at
this stage. (I.E. what does subform 2 display if subform 1 is showing the
last record?)

In the On Current event for subform 1 I put this:
On Error Resume Next
[Forms]![The Form]![Subform 2].Form.Recordset.AbsolutePosition =
Me.Recordset.AbsolutePosition + 1

On Error Resume Next is necessary, because subform 1 loads before subform 2,
and tries to refer to subform 2 before it has loaded, causing a runtime error.

In the On Load event for subform 2 I put this:

Me.Recordset.AbsolutePosition = [Forms]![Delete This Form]![Delete This Form
First subform].Form.Recordset.AbsolutePosition + 1

This generates an error saying the argument is of the wrong type. Given that
the syntax is identical to the code in the other subform, I am stumped as to
why.

Anyone else got any good ideas???

David

Russ said:
I've got 2 subforms on another form. Each one of them is displaying
the same data from a query. I am using two subforms so I can see
adjacent records in a table, and then do some math calculations with
them. Can I manipulate these sub-forms somehow so that when I advance
or go back one record on one of them, the other sub-form will also
advance/go back one record?

I would like to keep them always separated so I see different adjacent
records. This is being done to calculate water payments for a rural
water district.

Russ
Access 2000
 
R

Russ

Thanks for the effort Dave. As a workaround I will probably add an
additional field to the table so it will store both the new reading
and the old reading in each record. Then just keep my cursor near the
record navigation buttons.

Russ

Hi Russ

I got as far as I could do with this one I'm afraid. I just couldn't find a
way around that error. You could try to repost I guess.

Cheers

David

Russ said:
Dave,

I can answer one of the questions that you asked. When subform 1 is
at the last record, subform 2 should show a new record. That way a
new water reading can be entered.

Russ

Russ

I tried to solve this problem using the AbsolutePosition property of the
recordsets for the subforms. You can access the AbsolutePosition like this:

[Forms]![Form Name]![Subform Name].Form.Recordset.AbsolutePosition

There are two things you need to do:

1) When you change record in subform 1, change the record in subform 2 to
the one after the record in subform 1.
2) When subform 2 loads for the first time, change its record to be the one
after the record in subform 1.

You also need to deal with BOF and EOF situations, but I didn't bother at
this stage. (I.E. what does subform 2 display if subform 1 is showing the
last record?)

In the On Current event for subform 1 I put this:
On Error Resume Next
[Forms]![The Form]![Subform 2].Form.Recordset.AbsolutePosition =
Me.Recordset.AbsolutePosition + 1

On Error Resume Next is necessary, because subform 1 loads before subform 2,
and tries to refer to subform 2 before it has loaded, causing a runtime error.

In the On Load event for subform 2 I put this:

Me.Recordset.AbsolutePosition = [Forms]![Delete This Form]![Delete This Form
First subform].Form.Recordset.AbsolutePosition + 1

This generates an error saying the argument is of the wrong type. Given that
the syntax is identical to the code in the other subform, I am stumped as to
why.

Anyone else got any good ideas???

David

:

I've got 2 subforms on another form. Each one of them is displaying
the same data from a query. I am using two subforms so I can see
adjacent records in a table, and then do some math calculations with
them. Can I manipulate these sub-forms somehow so that when I advance
or go back one record on one of them, the other sub-form will also
advance/go back one record?

I would like to keep them always separated so I see different adjacent
records. This is being done to calculate water payments for a rural
water district.

Russ
Access 2000
 
Top