Here is my issue...
I have ComboBox that has the listfillrange pointed at a range that is filled via Access Data Connection (customer database) which is imported into excel as a table when opening the workbook. I then have it bound to cell G7 which fills with the value of the ComboBox. The ComboBox simply works as a customer search box and enters the value in g7. From there I use "vlookups", based on the value in g7, to complete the rest of the contact information in my excel worksheet.
I then have a command button to "Edit Current Customer" which when clicked uses the value in g7 to open an Access Form filled with the selected customers data. I make my changes, then click a "save and return" button to go back to excel.
Once back in excel I have a "lost focus" macro on the command button to refresh the Access Database in Excel. This works good but the problem I have is that when the Excel Table is refreshed, the value of the ComboBox changes, which is very annoying, because you then have to "re find" the customer you just edited.
My question is, how do I keep the value of the ComboBox or G7 from changing after the table is refreshed?
This is what I have tried.. seems like it should work, but it doesn't.
Thanks for any ideas!
Mark
I have ComboBox that has the listfillrange pointed at a range that is filled via Access Data Connection (customer database) which is imported into excel as a table when opening the workbook. I then have it bound to cell G7 which fills with the value of the ComboBox. The ComboBox simply works as a customer search box and enters the value in g7. From there I use "vlookups", based on the value in g7, to complete the rest of the contact information in my excel worksheet.
I then have a command button to "Edit Current Customer" which when clicked uses the value in g7 to open an Access Form filled with the selected customers data. I make my changes, then click a "save and return" button to go back to excel.
Once back in excel I have a "lost focus" macro on the command button to refresh the Access Database in Excel. This works good but the problem I have is that when the Excel Table is refreshed, the value of the ComboBox changes, which is very annoying, because you then have to "re find" the customer you just edited.
My question is, how do I keep the value of the ComboBox or G7 from changing after the table is refreshed?
This is what I have tried.. seems like it should work, but it doesn't.
Code:
Private Sub btnEditSpCust_LostFocus()
Dim LCategoryID As String
LCategoryID = Range("g7").Value
ActiveWorkbook.Connections("Customer Contact DB").Refresh
ActiveWorkbook.Sheets(1).Range("g7") = LCategoryID
End Sub
Thanks for any ideas!
Mark