Subform number

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

Guest

I have looked at www.lebans.com and found what looks like a solution to my
problem. I need to number each row in the subform but I also need to use that
number in a query or table.
Using '=RowNum([Form])' returns the correct numbering but does not seem to
populate any table records.
Am I just missing the obvious here?!
 
This is what I use in the Current event of my subform. It works by using the
default value of a textbox named txtLine which is bound to a field in the
subform's underlying table with the name of Line.:

Private Sub Form_Current()
On Error Resume Next
Dim x As Integer

x = DMax("Line", "YourTableName", "ID =" & Forms!YourMainFormName!ID)

If IsNull(x) Then
Me.txtLine.DefaultValue = 1
Else
Me.txtLine.DefaultValue = x + 1
End If

End Sub

The code numbering every set of records in the subform based on the ID of
the mainform. If you delete the last record it will not lose the next value,
but if you delete a previous record, your sequence will not renumber.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Thanks Arvin,
I tried that out but keep getting a "1" return.
I think my problem must be in the ID?!
By 'YourMainFormName' I presume that is the name of the form that we are
working in (i.e. main form). I can't really seem to figure what's wrong as
the formula looks like it should work.

Arvin Meyer said:
This is what I use in the Current event of my subform. It works by using the
default value of a textbox named txtLine which is bound to a field in the
subform's underlying table with the name of Line.:

Private Sub Form_Current()
On Error Resume Next
Dim x As Integer

x = DMax("Line", "YourTableName", "ID =" & Forms!YourMainFormName!ID)

If IsNull(x) Then
Me.txtLine.DefaultValue = 1
Else
Me.txtLine.DefaultValue = x + 1
End If

End Sub

The code numbering every set of records in the subform based on the ID of
the mainform. If you delete the last record it will not lose the next value,
but if you delete a previous record, your sequence will not renumber.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Graeme at Raptup said:
I have looked at www.lebans.com and found what looks like a solution to my
problem. I need to number each row in the subform but I also need to use that
number in a query or table.
Using '=RowNum([Form])' returns the correct numbering but does not seem to
populate any table records.
Am I just missing the obvious here?!
 
It's been working for me for 8 years. If you'd like, I can drop a version in
either Access 97 or A2K at the
http://www.accessmvp.com website later today.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Graeme at Raptup said:
Thanks Arvin,
I tried that out but keep getting a "1" return.
I think my problem must be in the ID?!
By 'YourMainFormName' I presume that is the name of the form that we are
working in (i.e. main form). I can't really seem to figure what's wrong as
the formula looks like it should work.

Arvin Meyer said:
This is what I use in the Current event of my subform. It works by using the
default value of a textbox named txtLine which is bound to a field in the
subform's underlying table with the name of Line.:

Private Sub Form_Current()
On Error Resume Next
Dim x As Integer

x = DMax("Line", "YourTableName", "ID =" & Forms!YourMainFormName!ID)

If IsNull(x) Then
Me.txtLine.DefaultValue = 1
Else
Me.txtLine.DefaultValue = x + 1
End If

End Sub

The code numbering every set of records in the subform based on the ID of
the mainform. If you delete the last record it will not lose the next value,
but if you delete a previous record, your sequence will not renumber.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Graeme at Raptup said:
I have looked at www.lebans.com and found what looks like a solution to my
problem. I need to number each row in the subform but I also need to
use
that
number in a query or table.
Using '=RowNum([Form])' returns the correct numbering but does not seem to
populate any table records.
Am I just missing the obvious here?!
 
A2K would be great,
I think I figured that the ID has to be a numeric field?
Cheers,
Graeme

Arvin Meyer said:
It's been working for me for 8 years. If you'd like, I can drop a version in
either Access 97 or A2K at the
http://www.accessmvp.com website later today.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Graeme at Raptup said:
Thanks Arvin,
I tried that out but keep getting a "1" return.
I think my problem must be in the ID?!
By 'YourMainFormName' I presume that is the name of the form that we are
working in (i.e. main form). I can't really seem to figure what's wrong as
the formula looks like it should work.

Arvin Meyer said:
This is what I use in the Current event of my subform. It works by using the
default value of a textbox named txtLine which is bound to a field in the
subform's underlying table with the name of Line.:

Private Sub Form_Current()
On Error Resume Next
Dim x As Integer

x = DMax("Line", "YourTableName", "ID =" & Forms!YourMainFormName!ID)

If IsNull(x) Then
Me.txtLine.DefaultValue = 1
Else
Me.txtLine.DefaultValue = x + 1
End If

End Sub

The code numbering every set of records in the subform based on the ID of
the mainform. If you delete the last record it will not lose the next value,
but if you delete a previous record, your sequence will not renumber.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

message I have looked at www.lebans.com and found what looks like a solution to my
problem. I need to number each row in the subform but I also need to use
that
number in a query or table.
Using '=RowNum([Form])' returns the correct numbering but does not seem to
populate any table records.
Am I just missing the obvious here?!
 
This one creates its own number using the code below:

http://www.accessmvp.com/Arvin/Index.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Graeme at Raptup said:
A2K would be great,
I think I figured that the ID has to be a numeric field?
Cheers,
Graeme

Arvin Meyer said:
It's been working for me for 8 years. If you'd like, I can drop a version in
either Access 97 or A2K at the
http://www.accessmvp.com website later today.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Graeme at Raptup said:
Thanks Arvin,
I tried that out but keep getting a "1" return.
I think my problem must be in the ID?!
By 'YourMainFormName' I presume that is the name of the form that we are
working in (i.e. main form). I can't really seem to figure what's wrong as
the formula looks like it should work.

:

This is what I use in the Current event of my subform. It works by
using
the
default value of a textbox named txtLine which is bound to a field
in
the
subform's underlying table with the name of Line.:

Private Sub Form_Current()
On Error Resume Next
Dim x As Integer

x = DMax("Line", "YourTableName", "ID =" & Forms!YourMainFormName!ID)

If IsNull(x) Then
Me.txtLine.DefaultValue = 1
Else
Me.txtLine.DefaultValue = x + 1
End If

End Sub

The code numbering every set of records in the subform based on the
ID
of
the mainform. If you delete the last record it will not lose the
next
value,
but if you delete a previous record, your sequence will not renumber.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

message I have looked at www.lebans.com and found what looks like a
solution
to my
problem. I need to number each row in the subform but I also need
to
use
that
number in a query or table.
Using '=RowNum([Form])' returns the correct numbering but does not seem to
populate any table records.
Am I just missing the obvious here?!
 
Arvin,
I only see 3 downloads Sample, Combo & Hyperlink.
Where am I meant to be looking?


Arvin Meyer said:
This one creates its own number using the code below:

http://www.accessmvp.com/Arvin/Index.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Graeme at Raptup said:
A2K would be great,
I think I figured that the ID has to be a numeric field?
Cheers,
Graeme

Arvin Meyer said:
It's been working for me for 8 years. If you'd like, I can drop a version in
either Access 97 or A2K at the
http://www.accessmvp.com website later today.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

message Thanks Arvin,
I tried that out but keep getting a "1" return.
I think my problem must be in the ID?!
By 'YourMainFormName' I presume that is the name of the form that we are
working in (i.e. main form). I can't really seem to figure what's wrong as
the formula looks like it should work.

:

This is what I use in the Current event of my subform. It works by using
the
default value of a textbox named txtLine which is bound to a field in
the
subform's underlying table with the name of Line.:

Private Sub Form_Current()
On Error Resume Next
Dim x As Integer

x = DMax("Line", "YourTableName", "ID =" & Forms!YourMainFormName!ID)

If IsNull(x) Then
Me.txtLine.DefaultValue = 1
Else
Me.txtLine.DefaultValue = x + 1
End If

End Sub

The code numbering every set of records in the subform based on the ID
of
the mainform. If you delete the last record it will not lose the next
value,
but if you delete a previous record, your sequence will not renumber.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

message I have looked at www.lebans.com and found what looks like a solution
to my
problem. I need to number each row in the subform but I also need to
use
that
number in a query or table.
Using '=RowNum([Form])' returns the correct numbering but does not
seem to
populate any table records.
Am I just missing the obvious here?!
 
Go look again (or refresh your browser, in case you've got the page cached).
There are now 5 download there, the last two being LineNumbers.zip and
LineNumbers2K.zip

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Graeme at Raptup said:
Arvin,
I only see 3 downloads Sample, Combo & Hyperlink.
Where am I meant to be looking?


Arvin Meyer said:
This one creates its own number using the code below:

http://www.accessmvp.com/Arvin/Index.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Graeme at Raptup said:
A2K would be great,
I think I figured that the ID has to be a numeric field?
Cheers,
Graeme

:

It's been working for me for 8 years. If you'd like, I can drop a version in
either Access 97 or A2K at the
http://www.accessmvp.com website later today.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

in
message Thanks Arvin,
I tried that out but keep getting a "1" return.
I think my problem must be in the ID?!
By 'YourMainFormName' I presume that is the name of the form that
we are
working in (i.e. main form). I can't really seem to figure what's wrong as
the formula looks like it should work.

:

This is what I use in the Current event of my subform. It works
by using
the
default value of a textbox named txtLine which is bound to a
field in
the
subform's underlying table with the name of Line.:

Private Sub Form_Current()
On Error Resume Next
Dim x As Integer

x = DMax("Line", "YourTableName", "ID =" & Forms!YourMainFormName!ID)

If IsNull(x) Then
Me.txtLine.DefaultValue = 1
Else
Me.txtLine.DefaultValue = x + 1
End If

End Sub

The code numbering every set of records in the subform based on
the ID
of
the mainform. If you delete the last record it will not lose the next
value,
but if you delete a previous record, your sequence will not renumber.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

"Graeme at Raptup" <[email protected]>
wrote in
message
I have looked at www.lebans.com and found what looks like a solution
to my
problem. I need to number each row in the subform but I also
need to
use
that
number in a query or table.
Using '=RowNum([Form])' returns the correct numbering but does
not
seem to
populate any table records.
Am I just missing the obvious here?!
 

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

Back
Top