ListBox not updating selected record

Synapsis

New Member
Joined
Jun 12, 2018
Messages
1
Hi to all and I'm glad to be here.
I use Excel but I am no expert and much I do is trial and eroor at times.

I trying to make a program to keep track o production. I have a main page where I have my command buttons that open forms to edit data.

The form opens and I recall a listbox for the item in production Status, I select the item and its put into the cells on the form after change the cells
I write this data back to the listbox and page. Well thats whats it supposed to do. Problem is if I run it from the main page it will not update the records
but if I run it from the sheet where the records are it work.
Here is the code
Code:
Private Sub CommandButton1_Click()
  
 Dim i As Long
  For i = 1 To Application.WorksheetFunction.CountA(Range("A:A"))
   For x = 1 To 9
    If Sheet6.Cells(i, "A").Value = Me.TextBox1.Text Then
    Sheet6.Cells(i, x).Value = Me("TextBox" & x).Value
    End If
Next x
Next i
  
End Sub

Private Sub ShowProduzione_Click()

Produzione.ColumnCount = 9
Produzione.RowSource = "Movimenti!A:I"

End Sub

Private Sub Produzione_AfterUpdate()

   Me.TextBox1.Value = Me.Produzione.Column(0)
    Me.TextBox2.Value = CDate(Me.Produzione.Column(1))
    Me.TextBox3.Value = Format(Me.Produzione.Column(2), "hh:mm")
    Me.TextBox4.Value = CDate(Me.Produzione.Column(3))
    Me.TextBox5.Value = Format(Me.Produzione.Column(4), "hh:mm")
    Me.TextBox6.Value = Format(Me.Produzione.Column(5), "hh:mm")
    Me.TextBox7.Value = Me.Produzione.Column(6)
    Me.TextBox8.Value = Me.Produzione.Column(7)
    Me.TextBox9.Value = Me.Produzione.Column(8)
  
 Dim i As Long
  For i = 1 To Application.WorksheetFunction.CountA(Range("A:A"))
   For x = 1 To 9
    If Sheet6.Cells(i, "A").Value = Me.TextBox1.Text Then
     Me("TextBox" & x).Value = Sheet6.Cells(i, x).Value
    End If
Next x
Next i

End Sub

Also I can't get the textboxs to format as hh:mm the ones in the listbox work but if I try to use for example

Code:
Me.TextBox6.Value = Format(Me.Textbox6.Value, "hh:mm")
its does not work.

Thanks for any help.
 
Last edited by a moderator:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top