I have a mutli form db app. The main form uses multiple listview to display data. Double clicking on an item in a listview opens another form with more detailed information relating to that item (a bit like in an address book app). On closing the second form I want the listview in the first form to refresh. I have a sub using Select Case to refresh only the list view that contains the item that has been opened but I'm having trouble passing the listviewname to it. The two subs I'm having trouble with are below, can anyone see any glaring errors with them? The RefreshListView(<bla bla>) routine are not being called from FillList()
THIS SUB IS CALLED WHEN THE USER DOUBLE CLICKS AN ITEM TO OPEN THE NEW FORM...
Regards,
Russ
http://www.russgreen.net/software/
THIS SUB IS CALLED WHEN THE USER DOUBLE CLICKS AN ITEM TO OPEN THE NEW FORM...
Visual Basic:
Private Sub OpenSelected(ByVal listviewname, ByVal DataTable, ByVal DataID, ByVal FormTitle)
On Error Resume Next
Dim x As Long
x = listviewname.Items(0).Text
Dim frm As New frmContactDet()
With frm
'Here we are going to Open the Dataset for the Item
Dim ds As New DataSet()
Dim da As OleDbDataAdapter = New OleDbDataAdapter()
'Declare and Open OLEDBCONNECTION FOR Access2k database
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dbFullPath)
conn.Open()
da.SelectCommand = New OleDbCommand("SELECT * FROM " & DataTable & " WHERE " & DataID & "=" & CLng(listviewname.SelectedItems(0).Tag), conn)
da.Fill(ds)
Dim dr As DataRow
'Now we have the Record - Hopefully
If ds.Tables(0).Rows.Count > 0 Then
dr = ds.Tables(0).Rows(0)
.lngContactID = dr(DataID)
End If
.MyTitle = FormTitle
.strDataTable = DataTable
.strContactID = DataID
dr = Nothing
da.Dispose()
ds.Dispose()
conn.Close()
.ShowDialog(Me)
'THIS SHOULD REFRESH THE ORIGINATING LISTVIEW BUT DOESN'T
'WHEN FILLALLLISTS() GETS CALLED HERE INSTEAD EVERYTHING WORKS OK
FillList(listviewname)
End With
End Sub
Visual Basic:
Private Sub FillList(ByVal listview)
Select Case listview
Case lvwProjectsActive
RefreshProjectsActive()
Case lvwProjectsClosed
RefreshProjectsClosed()
Case lvwClientPvt
RefreshClientPvt()
Case lvwClientCorp
RefreshListView(Me.lvwClientCorp, "ClientCorp", "ClientCorpID")
Case lvwArchitect
RefreshListView(Me.lvwArchitect, "Architect", "ArchitectID")
Case lvwLandArch
RefreshListView(Me.lvwLandArch, "LandArch", "LandArchID")
Case lvwStrucEng
RefreshListView(Me.lvwStrucEng, "StrucEng", "StrucEngID")
Case lvwServEng
RefreshListView(Me.lvwServEng, "ServEng", "ServEngID")
Case lvwQuantSurv
RefreshListView(Me.lvwQuantSurv, "QuantSurv", "QuantSurvID")
Case lvwProjMan
RefreshListView(Me.lvwProjMan, "ProjMan", "ProjManID")
Case lvwContractor
RefreshListView(Me.lvwContractor, "Contractor", "ContractorID")
End Select
End Sub
Visual Basic:
Private Sub FillAllLists()
'fill list boxes from database
RefreshProjectsActive()
RefreshProjectsClosed()
RefreshClientPvt()
RefreshListView(Me.lvwClientCorp, "ClientCorp", "ClientCorpID")
RefreshListView(Me.lvwArchitect, "Architect", "ArchitectID")
RefreshListView(Me.lvwLandArch, "LandArch", "LandArchID")
RefreshListView(Me.lvwStrucEng, "StrucEng", "StrucEngID")
RefreshListView(Me.lvwServEng, "ServEng", "ServEngID")
RefreshListView(Me.lvwQuantSurv, "QuantSurv", "QuantSurvID")
RefreshListView(Me.lvwProjMan, "ProjMan", "ProjManID")
RefreshListView(Me.lvwContractor, "Contractor", "ContractorID")
End Sub
Regards,
Russ
http://www.russgreen.net/software/