Decimal number with ListCount in the expression

J

JimAA

Hi,
I have a text box on a form (ChangeOrderSeq) where I would like to display a
number based on the count of records and a the result from a yes/no box
(NoteOnly). For sorting purposes I need that number to be have one decimal
place precision. I can't get the number to show decimal places. The table
field data type for ChangeOrderSeq is "Number" and field size is "Decimal".
The ChangeOrderSeq text box on the form is formatted to General Number and
one decimal place. Is there something with ListCount that only allows the
numbers to be whole?
Below if the code that I used.
Thanks

Private Sub BtnAddNew_Click()
On Error GoTo Err_BtnAddNew_Click

DoCmd.GoToRecord , , acNewRec
Me.ChangeOrderSeq.SetFocus
If Me.NoteOnly = 0 Then_
Me.ChangeOrderSeq = Me.LstDetailID.ListCount + 1 -
((DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1")))_
Else: Me.ChangeOrderSeq = Me.LstDetailID.ListCount + 0.9 -
(((DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1"))))_
End If

Exit_BtnAddNew_Click:
Exit Sub

Err_BtnAddNew_Click:
MsgBox Err.Description
Resume Exit_BtnAddNew_Click

End Sub
 
D

Douglas J. Steele

Well, by definition ListCount is an integer value: it represents the number
of rows in a list box or the list box portion of a combo box.

You're moving to a new record, which means that NoteOnly will always have
the same value, so I don't really understand what you're trying to do.
 
J

JimAA

I have a report that lists items (or a records) in a contract change order.
The record includes the Change Order Sequence number, a description of the
change and the cost of the change. Each line item is sorted by number
(ChangeOrderSeq). Sometimes when listing a group of similar items I want a
record that only displays a description (or a NoteOnly) without the sequence
number or cost shown. The expression in my code gives me the same sequence
number for a "NoteOnly" record as for the following record that I want
displaying the number, description and cost. When I run a report the
"NoteOnly" is listed after the record that displays the number, description
and cost. I thought that by adding 0.9 to the ListCount total for the
NoteOnly record would give that record a value 0.1 less than the next record
and therefore list it before the record that I want in my report. But the
values for each record are the same and I can't show it as a decimal.
Hope this makes sense.

Douglas J. Steele said:
Well, by definition ListCount is an integer value: it represents the number
of rows in a list box or the list box portion of a combo box.

You're moving to a new record, which means that NoteOnly will always have
the same value, so I don't really understand what you're trying to do.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


JimAA said:
Hi,
I have a text box on a form (ChangeOrderSeq) where I would like to display
a
number based on the count of records and a the result from a yes/no box
(NoteOnly). For sorting purposes I need that number to be have one
decimal
place precision. I can't get the number to show decimal places. The
table
field data type for ChangeOrderSeq is "Number" and field size is
"Decimal".
The ChangeOrderSeq text box on the form is formatted to General Number and
one decimal place. Is there something with ListCount that only allows the
numbers to be whole?
Below if the code that I used.
Thanks

Private Sub BtnAddNew_Click()
On Error GoTo Err_BtnAddNew_Click

DoCmd.GoToRecord , , acNewRec
Me.ChangeOrderSeq.SetFocus
If Me.NoteOnly = 0 Then_
Me.ChangeOrderSeq = Me.LstDetailID.ListCount + 1 -
((DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1")))_
Else: Me.ChangeOrderSeq = Me.LstDetailID.ListCount + 0.9 -
(((DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1"))))_
End If

Exit_BtnAddNew_Click:
Exit Sub

Err_BtnAddNew_Click:
MsgBox Err.Description
Resume Exit_BtnAddNew_Click

End Sub
 
D

Douglas J. Steele

It's not clear to me what

If Me.NoteOnly = 0 Then

is supposed to accomplish.

The line of code

DoCmd.GoToRecord , , acNewRec

causes execution to move to a new record, meaning that all bound fields will
have their default values.

Does it make a difference if you calculate the value before moving to the
new record?

Private Sub BtnAddNew_Click()
On Error GoTo Err_BtnAddNew_Click

Dim sngValue As Single

If Me.NoteOnly = 0 Then
sngValue = Me.LstDetailID.ListCount + 1 -
DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1")
Else
sngValue = Me.LstDetailID.ListCount + 0.9 -
DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1")
End If
DoCmd.GoToRecord , , acNewRec
Me.ChangeOrderSeq = sngValue

Exit_BtnAddNew_Click:
Exit Sub

Err_BtnAddNew_Click:
MsgBox Err.Description
Resume Exit_BtnAddNew_Click

End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JimAA said:
I have a report that lists items (or a records) in a contract change order.
The record includes the Change Order Sequence number, a description of the
change and the cost of the change. Each line item is sorted by number
(ChangeOrderSeq). Sometimes when listing a group of similar items I want a
record that only displays a description (or a NoteOnly) without the
sequence
number or cost shown. The expression in my code gives me the same sequence
number for a "NoteOnly" record as for the following record that I want
displaying the number, description and cost. When I run a report the
"NoteOnly" is listed after the record that displays the number,
description
and cost. I thought that by adding 0.9 to the ListCount total for the
NoteOnly record would give that record a value 0.1 less than the next
record
and therefore list it before the record that I want in my report. But the
values for each record are the same and I can't show it as a decimal.
Hope this makes sense.

Douglas J. Steele said:
Well, by definition ListCount is an integer value: it represents the
number
of rows in a list box or the list box portion of a combo box.

You're moving to a new record, which means that NoteOnly will always have
the same value, so I don't really understand what you're trying to do.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


JimAA said:
Hi,
I have a text box on a form (ChangeOrderSeq) where I would like to
display
a
number based on the count of records and a the result from a yes/no box
(NoteOnly). For sorting purposes I need that number to be have one
decimal
place precision. I can't get the number to show decimal places. The
table
field data type for ChangeOrderSeq is "Number" and field size is
"Decimal".
The ChangeOrderSeq text box on the form is formatted to General Number
and
one decimal place. Is there something with ListCount that only allows
the
numbers to be whole?
Below if the code that I used.
Thanks

Private Sub BtnAddNew_Click()
On Error GoTo Err_BtnAddNew_Click

DoCmd.GoToRecord , , acNewRec
Me.ChangeOrderSeq.SetFocus
If Me.NoteOnly = 0 Then_
Me.ChangeOrderSeq = Me.LstDetailID.ListCount + 1 -
((DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1")))_
Else: Me.ChangeOrderSeq = Me.LstDetailID.ListCount + 0.9 -
(((DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1"))))_
End If

Exit_BtnAddNew_Click:
Exit Sub

Err_BtnAddNew_Click:
MsgBox Err.Description
Resume Exit_BtnAddNew_Click

End Sub
 
J

JimAA

My form has a button that adds a new record and the focus is set to the
ChangeOrderSeq text box. In that box I am trying to generate sequential
numbers for all of the items in a change order. For appearance sake, the
records designated as NoteOnly do not have the ChangeOrderSeq number
displayed. I have a check box for that detail item that if checked the Seq #
and cost are not visible.
I have a list box in the header of my form that displays a summary of all of
the items (records) in the change order. In the detail section I have the
NoteOnly check box. The ChangeOrderSeq text box is also part of the detail.
The code is supposed to calculate the next detail item number
(ChangeOrderSeq) based on the items already in the list box in the header.
The problem is that the code generates the same number for a record following
a NoteOnly box that is checked.
If Me.NoteOnly = 0 Then generates the next number in sequence if the
NoteOnly box is not checked (the number of items in the listbox +1). If the
NoteOnly box is checked then I want the number generated to be the number of
items in the listbox + 0.9 to give it a smaller value so when sorting in my
report the NoteOnly is before the next detail item.

Douglas J. Steele said:
It's not clear to me what

If Me.NoteOnly = 0 Then

is supposed to accomplish.

The line of code

DoCmd.GoToRecord , , acNewRec

causes execution to move to a new record, meaning that all bound fields will
have their default values.

Does it make a difference if you calculate the value before moving to the
new record?

Private Sub BtnAddNew_Click()
On Error GoTo Err_BtnAddNew_Click

Dim sngValue As Single

If Me.NoteOnly = 0 Then
sngValue = Me.LstDetailID.ListCount + 1 -
DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1")
Else
sngValue = Me.LstDetailID.ListCount + 0.9 -
DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1")
End If
DoCmd.GoToRecord , , acNewRec
Me.ChangeOrderSeq = sngValue

Exit_BtnAddNew_Click:
Exit Sub

Err_BtnAddNew_Click:
MsgBox Err.Description
Resume Exit_BtnAddNew_Click

End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JimAA said:
I have a report that lists items (or a records) in a contract change order.
The record includes the Change Order Sequence number, a description of the
change and the cost of the change. Each line item is sorted by number
(ChangeOrderSeq). Sometimes when listing a group of similar items I want a
record that only displays a description (or a NoteOnly) without the
sequence
number or cost shown. The expression in my code gives me the same sequence
number for a "NoteOnly" record as for the following record that I want
displaying the number, description and cost. When I run a report the
"NoteOnly" is listed after the record that displays the number,
description
and cost. I thought that by adding 0.9 to the ListCount total for the
NoteOnly record would give that record a value 0.1 less than the next
record
and therefore list it before the record that I want in my report. But the
values for each record are the same and I can't show it as a decimal.
Hope this makes sense.

Douglas J. Steele said:
Well, by definition ListCount is an integer value: it represents the
number
of rows in a list box or the list box portion of a combo box.

You're moving to a new record, which means that NoteOnly will always have
the same value, so I don't really understand what you're trying to do.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi,
I have a text box on a form (ChangeOrderSeq) where I would like to
display
a
number based on the count of records and a the result from a yes/no box
(NoteOnly). For sorting purposes I need that number to be have one
decimal
place precision. I can't get the number to show decimal places. The
table
field data type for ChangeOrderSeq is "Number" and field size is
"Decimal".
The ChangeOrderSeq text box on the form is formatted to General Number
and
one decimal place. Is there something with ListCount that only allows
the
numbers to be whole?
Below if the code that I used.
Thanks

Private Sub BtnAddNew_Click()
On Error GoTo Err_BtnAddNew_Click

DoCmd.GoToRecord , , acNewRec
Me.ChangeOrderSeq.SetFocus
If Me.NoteOnly = 0 Then_
Me.ChangeOrderSeq = Me.LstDetailID.ListCount + 1 -
((DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1")))_
Else: Me.ChangeOrderSeq = Me.LstDetailID.ListCount + 0.9 -
(((DCount("[NoteOnly]", "qryChangeOrderDetails", "[NoteOnly]=-1"))))_
End If

Exit_BtnAddNew_Click:
Exit Sub

Err_BtnAddNew_Click:
MsgBox Err.Description
Resume Exit_BtnAddNew_Click

End Sub
 

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