Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing listbox or MSHFlexGrid

Status
Not open for further replies.

michellecole

Programmer
Feb 12, 2004
42
US
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 had this prob once too. What I ended up doing was re-executing the subroutine where the listbox was initially loaded. In my case, the subroutine was doing more than just loading a listbox, so I had to break down the subroutine into a few subroutines/functions to isolate the part I wanted to execute.

HTH

M.


ciao for niao!

AMACycle

American Motorcyclist Association
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top