Continuous Form Calculated Text box (1 Viewer)

Infinite

More left to learn.
Local time
Yesterday, 19:40
Joined
Mar 16, 2015
Messages
402
Hello! I have a form, and in there is a couple of text boxes, and labels. I want the user to click on the label, and I want

Code:
Private Sub Show1_Label_Click()
Me.Show1 = Me.BaseShow * 15
End Sub

But, when I click that, only the selected record is updated. I have 60 records, and I want the user to click that lots of times, so its multiplies it from 1, 1.25, 1.50, 1,75, etc, etc. But, if it only updates 1 record, that wont work. Any way to update ALL the records, instead of that one? Thanks!
 

Infinite

More left to learn.
Local time
Yesterday, 19:40
Joined
Mar 16, 2015
Messages
402
I have a Very, very long code to do as follows:

Code:
Private Sub Show1_Label_Click()
'====================Each click the multiplication factor is increased by 0.25=======

If Me.ShowOne = "3" Or Me.ShowOne = "One" Then
Me.Text34 = Me.BaseShow * 0.5
Me.ShowOne = 0.5
Me.Show1_Label.Caption = "Show-0.5"


ElseIf Me.ShowOne = 0.5 Then
Me.Text34 = Me.BaseShow * 0.75
Me.ShowOne = 0.75
Me.Show1_Label.Caption = "Show-0.75"

ElseIf Me.ShowOne = 0.75 Then
Me.Text34 = Me.BaseShow * 1
Me.ShowOne = 1
Me.Show1_Label.Caption = "Show-1"

ElseIf Me.ShowOne = 1 Then
Me.Text34 = Me.BaseShow * 1.25
Me.ShowOne = 1.25
Me.Show1_Label.Caption = "Show-1.25"

ElseIf Me.ShowOne = 1.25 Then
Me.Text34 = Me.BaseShow * 1.5
Me.ShowOne = 1.5
Me.Show1_Label.Caption = "Show-1.5"

ElseIf Me.ShowOne = 1.5 Then
Me.Show1 = Me.BaseShow * 1.75
Me.ShowOne = 1.75
Me.Show1_Label.Caption = "Show-1.75"

ElseIf Me.ShowOne = 1.75 Then
Me.Show1 = Me.BaseShow * 2
Me.ShowOne = 2
Me.Show1_Label.Caption = "Show-2"

ElseIf Me.ShowOne = 2 Then
Me.Show1 = Me.BaseShow * 2.25
Me.ShowOne = 2.25
Me.Show1_Label.Caption = "Show-2.25"

ElseIf Me.ShowOne = 2.25 Then
Me.Show1 = Me.BaseShow * 2.5
Me.ShowOne = 2.5
Me.Show1_Label.Caption = "Show-2.5"

ElseIf Me.ShowOne = 2.5 Then
Me.Show1 = Me.BaseShow * 2.75
Me.ShowOne = 2.75
Me.Show1_Label.Caption = "Show-2.75"

ElseIf Me.ShowOne = 2.75 Then
Me.Show1 = Me.BaseShow * 3
Me.ShowOne = 3
Me.Show1_Label.Caption = "Show-3"

End If

End Sub
'==============================================================================================================

Now that makes it so on click, the factor is increased by 0.25

A dont think a update query will do what I want. I want it on click, to happen right then. No update query, because that would take quite a while.
 
Last edited:

Infinite

More left to learn.
Local time
Yesterday, 19:40
Joined
Mar 16, 2015
Messages
402
So, no one has any ideas? Ive been thinking, looking up, and I still cant find any way reason its not.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 03:40
Joined
Jul 9, 2003
Messages
16,329
Hello! I have a form, and in there is a couple of text boxes, and labels. I want the user to click on the label, and I want

Code:
Private Sub Show1_Label_Click()
Me.Show1 = Me.BaseShow * 15
End Sub

But, when I click that, only the selected record is updated. I have 60 records, and I want the user to click that lots of times, so its multiplies it from 1, 1.25, 1.50, 1,75, etc, etc. But, if it only updates 1 record, that wont work. Any way to update ALL the records, instead of that one? Thanks!

Do you want the 60 records to update at the same time?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:40
Joined
May 7, 2009
Messages
19,246
Private Sub Show1_Label_Click()
dim varCurrentShow As Variant
If Me.ShowOne = "3" Or Me.ShowOne = "One" Then
Me.Text34 = Me.BaseShow * 0.5
Me.ShowOne = 0.5
Me.Show1_Label.Caption = "Show-0.5"

ELSE
varCurrent = CDec(Val( "0" & Me.ShowOne) + 0.25)
Me.text34 = Me.BaseShow * varCurrent
Me.ShowOne = varCurrent
Me.Show1_Label.Caption = "Show-" & Trim(varCurrent)

End If
 

Infinite

More left to learn.
Local time
Yesterday, 19:40
Joined
Mar 16, 2015
Messages
402
Thank you arnelgp! That really, really helped shorten the code! Thanks again!


Do you want the 60 records to update at the same time?

Yes, I do.
 

Infinite

More left to learn.
Local time
Yesterday, 19:40
Joined
Mar 16, 2015
Messages
402
Read arnelgps code. It should explain it.
 

Infinite

More left to learn.
Local time
Yesterday, 19:40
Joined
Mar 16, 2015
Messages
402
On every click, the number goes up. Currently, it only goes up for one column. I want it to go up on all of them.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:40
Joined
May 7, 2009
Messages
19,246
what are the columns (field) names that need to change.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:40
Joined
May 7, 2009
Messages
19,246
i advice to rename your controls, to be able to use the following code:
Show1, Show2, Show3
Text1, Text2, Text3
Show1_Label, Show2_Label, Show3_Label

code:
Private Sub Show1_Label()

Dim varCurrentShow As Variant
Dim i As Integer
For i = 1 To 3
varCurrentShow = 0.5
If Me.Controls("Show" & i).Value = "3" Or _
Me.Controls("Show" & i).Value = "One" Then
Else
varCurrent = CDec(Val("0" & Me.Controls("Show" & i).Value) + 0.25)
End If
Me.Controls("Text" & i).Value = Me.BaseShow * varCurrent
Me.Controls("Show" & i).Value = varCurrent
Me.Controls("Show" & Trim(i & "") & "_Label").Caption = "Show-" & Trim(varCurrent)
Next
End Sub
 

Infinite

More left to learn.
Local time
Yesterday, 19:40
Joined
Mar 16, 2015
Messages
402
Ohh! I think I know whats wrong. You think that the caption is not updating. It is, whats not updating is the records. Here is the SQL for the query, maybe im doing something wrong there. And attached is a image of the Form.


Code:
SELECT tblItems.Model, tblItems.ModelID, tblInventory.OnHand, tblInventory.BaseShow, tblInventory.Show1, tblInventory.Show2, tblInventory.Show3, Nz([Show1],0)+Nz([Show2],0)+Nz([Show3],0) AS ShowTotal, tblInventory.CutShow1, tblInventory.CutShow2, tblInventory.CutShow3, tblInventory.CutTotal
FROM tblInventory RIGHT JOIN tblItems ON tblInventory.IModelID = tblItems.ModelID
WHERE (((tblItems.Status)="Current") AND ((tblItems.Category)<>"Misc"))
ORDER BY tblItems.Model;

Thanks once again for your help Arnelgp!
 

Attachments

  • Capture.PNG
    Capture.PNG
    50.9 KB · Views: 32
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:40
Joined
May 7, 2009
Messages
19,246
you have to use the form's recordset in able to do that:
Code:
Dim varCurrentShow as Variant
Dim rsData as Recordset
Dim i As Integer

varCurrentShow = 0.5
set rsData = Me.RecordSetClone

With rsData
    If Not (.EOF AND .BOF) Then .MoveFirs
    While Not .EOF
        For i = 1 to 3
            Select Case .Fields("Show" & i).Value
            Case 1, 3
                varCurrentShow = 0.5
            Case Else
                varCurrentShow = .Fields("Show" & i).Value + 0.25
            End Select
            .Edit
            .Fields("Show" & i).Value = varCurrentShow
            .Update
        Next
        .MoveNext
    Wend
End With
rsData.Close
set rsData=Nothing
 

Users who are viewing this thread

Top Bottom