I have the code figured out how to populate the form with a specific record that can be entered into a field, and then upon updating that field on the form, the rest of the form is populated wiht that specific record (which is what I want... ) However, I cannot get it to paste the new (updated) data to the existing record (it only copies it over to a brand new record and not the one that it should be copying over top of)
Here is the code I have thus far:
Now here is where I cannot get it to place the data correctly onto the existing record that was selected:
I have found various methods of accomplishing this, but nothing I try i can make work (?) Thanks for any assistance offered.
Here is the code I have thus far:
Code:
Private Sub txtIncidentID1_AfterUpdate()
[COLOR=#006400]' Lookup Incident ID Number[/COLOR]
If WorksheetFunction.CountIf(Sheet1.Range("A:A"), Me.txtIncidentID1.Value) = 0 Then
[COLOR=#006400]' If no such ID exists:[/COLOR]
MsgBox "Incident ID not found."
Me.txtIncidentID1.Value = ""
End If
[COLOR=#006400]' ID is found so now the code is populating the rest of the user form with the data from that record linked to the specific IncidentID that was found:[/COLOR]
With Me
.DTPicker3 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 2, 0)
.cboLocation1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 6, 0)
.cboPriority1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 4, 0)
.txtCAPA1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 18, 0)
.cboCustomer1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 7, 0)
.txtProblem1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 8, 0)
.txtAction1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 9, 0)
.cboIssuedBy1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 10, 0)
.cboOnBehalfOf1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 11, 0)
.cboIssuedTo1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 12, 0)
.cboIssuedTo21 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 13, 0)
.txtCostProd1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 20, 0)
.txtCostShip1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 21, 0)
.txtCostConcess1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 22, 0)
.txtCostTravel1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 23, 0)
.txtCostFacility1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 24, 0)
.txtCostOther1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 25, 0)
.txtCost1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 16, 0)
.txtNotes1 = Application.WorksheetFunction.VLookup((Me.txtIncidentID1), Sheet1.Range("DynamicRange"), 19, 0)
Now here is where I cannot get it to place the data correctly onto the existing record that was selected:
I have found various methods of accomplishing this, but nothing I try i can make work (?) Thanks for any assistance offered.
Last edited: