Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    andr3ahh is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    8

    VBA Problem

    Hello! I am not really an expert of MS Access. All of a sudden, my DB stopped working and it shows a debugging problem on VBA.
    This is the code which is not working:
    Code:
    Private Sub Status_AfterUpdate()
    
        Dim strWhere As String
        Dim strError As String
        
        strWhere = "1=1"
         
        ' If Status
        If nz(Me.Status) <> "" Then
            'Add it to the predicate - exact match
            strWhere = strWhere & " AND " & "CODStato = '" & Me.Status & "'"
        End If
        
        If strError <> "" Then
            MsgBox strError
        Else
            'DoCmd.OpenForm "Browse Issues", acFormDS, , strWhere, acFormEdit, acWindowNormal
            If Not Me.FormFooter.Visible Then
                Me.FormFooter.Visible = True
                DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
            End If
    Me.smRichieste.Form.Filter = strWhere
    Me.smRichieste.Form.FilterOn = True
        End If
    
    
    End Sub
    Debugger shows that the problem is on those two highligted code parts.
    This is the error when I try to open my form: Runtime error '2455' - You entered an expression that has an invalid reference to the property Form/Report


    What could be the problem?

    Thank you!

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    If you a simply applying the filter to the form you are on then you should use
    Code:
    Me.Filter = strWhere
    Me.FIlterOn = True
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    andr3ahh is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    8
    The form no longer shows the error, but it doesn't show the sub-form (which should be filtered by the VB) anymore :/

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    but it doesn't show the sub-form (which should be filtered by the VB) anymore
    can you see the subform in design view? if not then it has been deleted. If it is visible, it is likely the subfrom control visible property has been set to false

  5. #5
    andr3ahh is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    8
    Yes, the form is visible... I guess that could be the problem, however, I don't know how to look it up :/

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    I don't know how to look it up
    in design view, click on 'properties' on the ribbon to open the properties window. Select the subform control and look for the visible property - should be at the top of the properties Format tab

  7. #7
    andr3ahh is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    8
    Thank you! It says "Visible: yes".

  8. #8
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    This may be caused by you setting a filter value that hides all the available subform records.

    Normally a sub form wouldn't be filtered, you would simply link it to the matching record in the parent form, using the Master Child subform container properties.
    It would then match the main form automatically?

    If this isn't applicable maybe you could explain, in simple terms, the purpose of the form(s) ?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  9. #9
    andr3ahh is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    8
    The problem was just like that! It was filtered, thank you!!! I now have a "second" question for both of you... Please see the two attached pictures below:
    Click image for larger version. 

Name:	bbbb.png 
Views:	24 
Size:	7.5 KB 
ID:	35592
    Click image for larger version. 

Name:	ccc.png 
Views:	24 
Size:	31.7 KB 
ID:	35593
    On the first picture, this form is called "ODS", you can "click" over those buttons (ATT/PART/TARG/T>H/OSP/LIBERO), and they will insert automatically the present time with a VBA Now() function.
    What I would really like to do is to do the same thing, insert present time, by double-clicking on another form (named "Richieste") the corresponding text (Which would be "Allertamento/Partito/Target/Target>Ospedale/Ospedale/Libero). Is this possible?
    Thank you very much for your kind help!

  10. #10
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    anything is possible, but I don't quite understand what you are asking - you want to populate a field with '"Allertamento/Partito/Target/Target>Ospedale/Ospedale/Libero' or the current time? by double clicking on a form?

  11. #11
    andr3ahh is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    8
    Quote Originally Posted by Ajax View Post
    anything is possible, but I don't quite understand what you are asking - you want to populate a field with '"Allertamento/Partito/Target/Target>Ospedale/Ospedale/Libero' or the current time? by double clicking on a form?
    Sorry if I didn't explain myself correctly. What I am trying to obtain is the current time by double-clicking over the nametags "Allertamento/Partito/Target/Target>Ospedale/Ospedale/Libero", instead of going inside the first form shown on the image and by clicking over the buttons "ATT" and so on. The two pictures are two separate forms of course. Thank you!

  12. #12
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    The forms detail section has a double click event. You can use that.

    You may need to make sure you reference the target control(s) correctly using the syntax explained here :http://access.mvps.org/access/forms/frm0031.htm
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    if you ensure the Allertamento label is unbound, you can use the double click event to populate the Allertamento control. Or leave it bound to the allermento control and double clicking on either to populate with now()

  14. #14
    andr3ahh is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    8
    Hmm, that didn’t work. Those two forms are not parent/child or form/subform... I’ve been trying various methods to do that, but as by now all of them were unsuccessful...

  15. #15
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    In your table, you have fields
    Allertamento (ATT)
    Partito (Part)
    Target (TARG)
    Target_Ospedale (T_H)
    Ospedale (OSP)
    Libero (LIBERO)

    Form "Richieste" is in Continuous Forms view and each record has 6 date/time fields.
    The label must be bound to the text box.

    Lets say the field name is "Allertamento" and the name of the bound text box is "ATT".
    (The name of the field in the table is "Allertamento" and the name of the Text box is "ATT")
    In the double click event of ATT, the code would be
    Code:
    Private Sub ATT_DblClick(Cancel As Integer)
        Me.ATT  = Time()
        Me.Refresh
    End Sub
    For the field name "Partito", the bound text box name would be "PART".
    In the double click event of "PART", the code would be
    Code:
    Private Sub PART_DblClick(Cancel As Integer)
        Me.PART = Time()
        Me.Refresh
    End Sub
    The rest of the time fields are set up with the same code.


    If you do not want anyone to manually change the time of a text box, set the enabled property to YES and the Locked property to YES. (edited)
    Last edited by ssanfu; 09-26-2018 at 03:27 PM.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 07-06-2015, 01:47 AM
  2. Replies: 2
    Last Post: 10-31-2012, 11:52 AM
  3. Replies: 2
    Last Post: 06-14-2010, 03:25 PM
  4. query problem i have a problem wi
    By maxx3 in forum Queries
    Replies: 0
    Last Post: 06-29-2009, 02:29 AM

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