This should be easy?!?!?

G

Guest

I have a form where the default view of the Detail Section is set at
‘Continuous Forms’. In the detail section I have several text boxes. I would
like to set one of the unbound text boxes as counter so the record at the top
of the form is number 1. etc… Is there an easy way to day this? It’s easy to
do in a report but I can’t figure out how do it in a form.
 
A

Albert D. Kallal

In the sub-forms code module, place a function like:

Public Function MyIx(Vid As Variant)

If IsNull(Vid) Then
Exit Function
End If

Me.RecordsetClone.FindFirst "id = " & Vid

MyIx = Me.RecordsetClone.AbsolutePosition + 1


End Function

the above assumes that you used the "default" id for the primary key.

Then, place a un-bound text box in on the continues form. For the data
source, just go:

=MyIx([id])

That is it...easy..and only about 5 lines of code....
 
G

Guest

Albert,

Thanks for the suggestion but I think this might not work for me as it is
more complicated than I need. The trouble with your solution is I don't have
a sub form within my main form. I just have a simple straight forward form;
with a header, detail, and footer section. What I want to do should be easy.
This is what is frustrating me.

All I want to do is display the record number, of each record, in a text
box, within the detail section.

I've contemplated querying the underlying data and making a new table that
has a "ID Code" field but this seems like a sloppy solution.

Peter

Albert D. Kallal said:
In the sub-forms code module, place a function like:

Public Function MyIx(Vid As Variant)

If IsNull(Vid) Then
Exit Function
End If

Me.RecordsetClone.FindFirst "id = " & Vid

MyIx = Me.RecordsetClone.AbsolutePosition + 1


End Function

the above assumes that you used the "default" id for the primary key.

Then, place a un-bound text box in on the continues form. For the data
source, just go:

=MyIx([id])

That is it...easy..and only about 5 lines of code....


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)





Hammer said:
I have a form where the default view of the Detail Section is set at
'Continuous Forms'. In the detail section I have several text boxes. I
would
like to set one of the unbound text boxes as counter so the record at the
top
of the form is number 1. etc. Is there an easy way to day this? It's easy
to
do in a report but I can't figure out how do it in a form.
 
A

Albert D. Kallal

The code solution posted will also work for a regular continuous form
also...
 
G

Guest

Albert,

I got my head out of my ass and re-read what you wrote. It worked like a
charm. Thanks

Albert D. Kallal said:
In the sub-forms code module, place a function like:

Public Function MyIx(Vid As Variant)

If IsNull(Vid) Then
Exit Function
End If

Me.RecordsetClone.FindFirst "id = " & Vid

MyIx = Me.RecordsetClone.AbsolutePosition + 1


End Function

the above assumes that you used the "default" id for the primary key.

Then, place a un-bound text box in on the continues form. For the data
source, just go:

=MyIx([id])

That is it...easy..and only about 5 lines of code....


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)





Hammer said:
I have a form where the default view of the Detail Section is set at
'Continuous Forms'. In the detail section I have several text boxes. I
would
like to set one of the unbound text boxes as counter so the record at the
top
of the form is number 1. etc. Is there an easy way to day this? It's easy
to
do in a report but I can't figure out how do it in a form.
 

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