Results 1 to 9 of 9
  1. #1
    atzdgreat is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2019
    Posts
    27

    How to requery listview control from subform.

    trying to requery my listview in subform wont work. this is form is a progressbar form.

    Code:
    Private Sub Form_Open(Cancel As Integer)
        Me.TimerInterval = 1
    End Sub
    
    
    Private Sub Form_Timer()
        Call CallTest
    End Sub
    
    
    Private Sub CallTest()
        'On Error GoTo ErrHandler
        Dim oWSHShell As Object
        Dim GetDesktop As String
        Dim objWorkbook As Workbook
        Dim rngData As Range
        Dim NewRngData As Range
        Dim RowCount As Long
        Dim i, y, x, z As Integer
        Dim li As ListItem
        Dim db As DAO.Database
        Dim rs As DAO.Recordset
        Dim DbName As String
        
        Set LV = Form_Test_Difference_Rept.lvExcelList.Object
        For i = 1 To 10
            Set li = LV.ListItems.Add(, , "test1")
                li.SubItems(1) = "test2"
                li.SubItems(2) = "test3"
                li.SubItems(3) = "test4"
        Next i
        Set li = Nothing
        Set LV = Nothing
        'FormsRequery "MainWindow"
        Form_MainWindow.ChildMainMenu.Form.Query
    Exit Sub
    Exit_MyProc:
        If Not li Is Nothing Then
            Set li = Nothing
        End If
        
        If Not LV Is Nothing Then
            Set LV = Nothing
        End If
        
        Exit Sub
    ErrHandler:
        msg = MsgBox("Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description & "! Kindly contact your Administrator.", vbExclamation, "Test Guide!")
        Resume Exit_MyProc
    End Sub


  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    what does 'won't work' mean? you get an error? form does not refresh? something else?

    Only thing I can see is you have set the timer to one thousandth of a second - actions such are requery probably take longer than that and I don't believe there is an action called 'query'

    would help if you explain in simple terms what you are trying to achieve - you talk of a listview (what type of control is that) and a progress bar

  3. #3
    atzdgreat is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2019
    Posts
    27
    sorry for that. i have a mainform which has a subform.
    Code:
    Me.SubForm.SourceObject = "Form_Test_Difference_Rept"

    now in Form_Test_Difference_Rept, i have a button "Update". when user press update, the form dialog shows (which is there is a progress bar)... data should be inserted in the listview (which is in subform) while loop statements run in form dialog. but it turns out, listview has no data

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    I don't see any code associated with a button event

    Also,

    1. have you got 'Option Explicit' at the top of each module, just below 'Option Compare Database'. If not, put it there and then debug your code
    2. have you stepped through your code to check the code you think is running is actually running

    in particular this bit of code which seems to be adding the same thing 10 times

    Code:
    For i = 1 To 10
            Set li = LV.ListItems.Add(, , "test1")
                li.SubItems(1) = "test2"
                li.SubItems(2) = "test3"
                li.SubItems(3) = "test4"
        Next i

  5. #5
    atzdgreat is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2019
    Posts
    27
    yes i have option explicit at the top of my module. the code is just fine. actually when i tried not using the subform and makes my "Form_Test_Difference_Rept" as my mainform. listview is doing fine. but when i call "Form_Test_Difference_Rept" thru subform, insertion in listview not working anymore. that's why i tried Form_MainWindow.ChildMainMenu.Form.Query inside and out the for statement but still no luck.

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    yes i have option explicit at the top of my module.
    And it compiles OK?

    And what happens when you step through the code?

    Also, have you turned off any error handling until this problem is resolved? Below would appear to be incorrect and would generate an error at runtime

    Which module is the CallTest sub in?

    If the main form then I would expect this

    Set LV = Form_Test_Difference_Rept.lvExcelList.Object

    to be


    Set LV = Form_Test_Difference_Rept.form.lvExcelList.Object (assuming Form_Test_Difference_Rept is the name of your subcontrol)



    if the subform then


    Set LV =lvExcelList.Object

  7. #7
    atzdgreat is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2019
    Posts
    27
    i tried this and still nothing happens..
    Code:
    Set LV = Form_MainWindow.ChildMainMenu.Form.lvExcelList.Object
    may because listview is not part of access control?

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    suggest respond to my other questions as well.

  9. #9
    atzdgreat is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Sep 2019
    Posts
    27
    figured it out.. thanks a lot.

    Code:
    Before:
        Form_MainWindow.ChildMainMenu.Width = Form_Test_Difference_Rept.Width
        Form_MainWindow.ChildMainMenu.Height = Form_Test_Difference_Rept.Details.Height
        Form_MainWindow.ChildMainMenu.Left = (Form_MainWindow.Width - Form_Test_Difference_Rept.Width) / 2
        Form_MainWindow.ChildMainMenu.Top = 200
        Form_MainWindow.ChildMainMenu.SourceObject = "Test_Difference_Rept"
    
    After:
        NewWidthSize = 'width of my "Test_Difference_Rept"
        NewHeightSize =  ' height of my "Test_Difference_Rept"
        NewFormName= "Test_Difference_Rept"
        Form_MainWindow.ChildMainMenu.Width = NewWidthSize
        Form_MainWindow.ChildMainMenu.Height = NewHeightSize
        Form_MainWindow.ChildMainMenu.Left = (Form_MainWindow.Width - NewWidthSize) / 2
        Form_MainWindow.ChildMainMenu.Top = 200
        Form_MainWindow.ChildMainMenu.SourceObject = NewFormName

Please reply to this thread with any new information or opinions.

Similar Threads

  1. MS ListView Control for office 2013
    By moodhi in forum Forms
    Replies: 2
    Last Post: 10-19-2017, 04:23 PM
  2. Requery Control On Subform
    By dweekley in forum Access
    Replies: 6
    Last Post: 05-01-2017, 11:49 AM
  3. ListView Control (ActiveX) in Ms.Access Form
    By ahmed_one in forum Access
    Replies: 18
    Last Post: 04-21-2015, 10:22 PM
  4. Replies: 5
    Last Post: 04-15-2015, 04:20 PM
  5. requery subform in tab Control
    By raffi in forum Forms
    Replies: 2
    Last Post: 10-16-2014, 12:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums