I have a user form for my users to enter data then, click the save button to save the data to a database. Once they click the save button the form resets to empty text boxes. After I added the below code 2 text boxes autopopulate based on the entry in a combobox. After clicking the Save command button these 2 textboxes do not clear and the debug message box displays. This line of code is highlighted .txtVendorAddress = Application.WorksheetFunction.VLookup((Me.cmbVendor), Sheet5.Range("A2:D30"), 2, 0). I'm learning vba as I go. I'm not sure how to fix this. If someone can give me some direction I would be thankful. This is my final step in completing this project.
Respectfully,
Joseph
Option Explicit
Private Sub cmbVendor_Change()
With Me
.txtVendorAddress = Application.WorksheetFunction.VLookup((Me.cmbVendor), Sheet5.Range("A2:D30"), 2, 0)
.txtVendorLocation = Application.WorksheetFunction.VLookup((Me.cmbVendor), Sheet5.Range("A2:D30"), 3, 0)
End With
End Sub
Respectfully,
Joseph
Option Explicit
Private Sub cmbVendor_Change()
With Me
.txtVendorAddress = Application.WorksheetFunction.VLookup((Me.cmbVendor), Sheet5.Range("A2:D30"), 2, 0)
.txtVendorLocation = Application.WorksheetFunction.VLookup((Me.cmbVendor), Sheet5.Range("A2:D30"), 3, 0)
End With
End Sub