michellecole
Programmer
I initially created a listbox with 2 columns with a click event to populate a form based on the CustomerID highlighted when the clicked. The listbox populates correctly when I initially load the form, but when I ADD or DELETE a record - the listbox won't display the new record or delete the highlighted record until I add or delete a second record.
I thought maybe there were limitations with the listbox so created a MSHFlexGrid to do the same and it is having the same issue.
The MSHFlexGrid is populated via a procedure, Populate_MSHFlexGridSearch, called by the form's load event. The Add and Delete buttons trigger the same procedure, Populate_MSHFlexGridSearch.
I've tried .clear, .refresh, etc. What am I doing wrong? I had similar code for the listbox and it wasn't working either.
Thank you,
Michelle
Here's are some code snippits...
Private Sub Form_Load()
Populate_MSHFlexGridSearch
End Sub
Public Sub Populate_MSHFlexGridSearch()
Dim sSQL As String
Dim rsSearch As ADODB.Recordset
Dim strRow As String
Set connRDB = New ADODB.Connection
connRDB.ConnectionString = "DSN=RemoteDepositBilling;UID=sa;PWD= ;DSQ=RemoteDepositBilling"
connRDB.Open
Set rsSearch = New ADODB.Recordset
sSQL = "SELECT CustomerID, CustomerName FROM tblCustomers WHERE IsRecActive = 'Yes' ORDER BY tblCustomers.CustomerID"
rsSearch.Open sSQL, connRDB, adOpenStatic, adLockReadOnly
Set MSHFlexGridSearch.DataSource = rsSearch
'added the next few lines to try and refresh but not working...
Set MSHFlexGridSearch.DataSource = Nothing
rsSearch.Requery
Set MSHFlexGridSearch.DataSource = rsSearch
MSHFlexGridSearch.Refresh
End Sub
I thought maybe there were limitations with the listbox so created a MSHFlexGrid to do the same and it is having the same issue.
The MSHFlexGrid is populated via a procedure, Populate_MSHFlexGridSearch, called by the form's load event. The Add and Delete buttons trigger the same procedure, Populate_MSHFlexGridSearch.
I've tried .clear, .refresh, etc. What am I doing wrong? I had similar code for the listbox and it wasn't working either.
Thank you,
Michelle
Here's are some code snippits...
Private Sub Form_Load()
Populate_MSHFlexGridSearch
End Sub
Public Sub Populate_MSHFlexGridSearch()
Dim sSQL As String
Dim rsSearch As ADODB.Recordset
Dim strRow As String
Set connRDB = New ADODB.Connection
connRDB.ConnectionString = "DSN=RemoteDepositBilling;UID=sa;PWD= ;DSQ=RemoteDepositBilling"
connRDB.Open
Set rsSearch = New ADODB.Recordset
sSQL = "SELECT CustomerID, CustomerName FROM tblCustomers WHERE IsRecActive = 'Yes' ORDER BY tblCustomers.CustomerID"
rsSearch.Open sSQL, connRDB, adOpenStatic, adLockReadOnly
Set MSHFlexGridSearch.DataSource = rsSearch
'added the next few lines to try and refresh but not working...
Set MSHFlexGridSearch.DataSource = Nothing
rsSearch.Requery
Set MSHFlexGridSearch.DataSource = rsSearch
MSHFlexGridSearch.Refresh
End Sub