Updating Data from Previously Submitted Form Entry
Hello,
I need help with the code for updating a data has has been submitted through a form. I have a form that is for recording our budget Purchase Orders. Sometimes we don't have the PO number right away, but still want to put in a place holder with the other data and then come back and add the PO number later. I need help with code that will let me scroll through the current list of submitted POs and be able to click an "update" button if I change/add the PO number (or any of the fields, if someone had entered it wrong).
I have added a scroll spin button and label to go through "x of x" record and an update button but need help with the coding, please!
Re: Updating Data from Previously Submitted Form Entry
Added an additional button to empty the controls for new entry.
Try this
PHP Code:
Private Sub CommandButton1_Click() With Sheet1 If Application.WorksheetFunction.CountIf(.Range("C:C"), CStr(Me.txtPO.Value)) > 0 Then iRow = .Range("C:C").Find(CStr(Me.txtPO.Value), , xlValues, xlWhole).Row Me.txtName.Value = .Cells(iRow, 1).Value Me.cboOwner.Value = .Cells(iRow, 2).Value Me.txtPO.Value = .Cells(iRow, 3).Value Me.txtPOAmount.Value = .Cells(iRow, 4).Value Me.cboBudget.Value = .Cells(iRow, 5).Value Me.txtDate.Value = .Cells(iRow, 6).Value End If End With End Sub
Private Sub SpinButton1_SpinDown() With Sheet1 If iRow = .Range("A" & Rows.Count).End(xlUp).Row Then MsgBox "It is the last record", vbInformation Else iRow = iRow + 1 Me.txtName.Value = .Cells(iRow, 1).Value Me.cboOwner.Value = .Cells(iRow, 2).Value Me.txtPO.Value = .Cells(iRow, 3).Value Me.txtPOAmount.Value = .Cells(iRow, 4).Value Me.cboBudget.Value = .Cells(iRow, 5).Value Me.txtDate.Value = .Cells(iRow, 6).Value End If End With End Sub
Private Sub SpinButton1_SpinUp() With Sheet1 If iRow = 2 Then MsgBox "It is the first record", vbInformation Else iRow = iRow - 1 Me.txtName.Value = .Cells(iRow, 1).Value Me.cboOwner.Value = .Cells(iRow, 2).Value Me.txtPO.Value = .Cells(iRow, 3).Value Me.txtPOAmount.Value = .Cells(iRow, 4).Value Me.cboBudget.Value = .Cells(iRow, 5).Value Me.txtDate.Value = .Cells(iRow, 6).Value End If End With End Sub
Last edited by ImranBhatti; 09-17-2018 at 03:03 PM.
Re: Updating Data from Previously Submitted Form Entry
the code you sent doesn't seem to have anything for updating an existing line. I need to be able to spin through the rows and then update something within one.
Re: Updating Data from Previously Submitted Form Entry
ImranBhatti, would you be able to help me with the code for the Invoices too? trying to do it myself but getting lost under the 'Private Sub UserForm_Initialize()' part...
Re: Updating Data from Previously Submitted Form Entry
Also, in POs once i click the up spin arrow a few times, i won't let me go back down. and if i click the invoice up arrow more than once it gives me an error
Re: Updating Data from Previously Submitted Form Entry
There are errors with both:
PO Form:
- once I click the up spin arrow a few times, it won't let me go back down
Invoice Form:
- The number of records don't show up right way, but they do once I click the arrow
- When I click the up arrow more than once it gives me an error and won't let me keep going
Re: Updating Data from Previously Submitted Form Entry
Originally Posted by heimk008
PO Form:
- once I click the up spin arrow a few times, it won't let me go back down
The file in that I have attached in post #9 is working fine for me.
Originally Posted by heimk008
Invoice Form:
- The number of records don't show up right way, but they do once I click the arrow
- When I click the up arrow more than once it gives me an error and won't let me keep going
Add the this line in the Userform_Initialize event of Invoice form
Bookmarks