Page 2 of 5 FirstFirst 12345 LastLast
Results 16 to 30 of 65
  1. #16
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Well, it wasn't meant to be hostile, it was meant to quote you on what you asked for (of which there are a few versions) vs what was given. I don't know why you keep raising the point of what MouseOver(name) does or doesn't do because I get it. What I wrote retrieves the name of the control that is moused over without the need to pass a parameter but I don't think you get that because you'll say you understand it but won't offer an interpretation. I also think that because you are again repeating what you want
    What I am looking for is a syntax that provides, at run time, some other values, in this specific case, the name of the control,
    which again, my code does (as far as the name of the control is concerned). It also does it without all that complicated class stuff - which is not to say it's better, just less complicated. The class version is a great opportunity to learn, that's for sure.
    I'm going to unsubscribe from this thread because I can't seem to get my message across and there's no point in aggravating you further. If you decide you have questions about my procedure, PM me otherwise I won't see your inquiries.


    Good luck with your quest.

  2. #17
    pdanes is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Micron View Post
    Well, it wasn't meant to be hostile, it was meant to quote you on what you asked for (of which there are a few versions) vs what was given. I don't know why you keep raising the point of what MouseOver(name) does or doesn't do because I get it. What I wrote retrieves the name of the control that is moused over without the need to pass a parameter but I don't think you get that because you'll say you understand it but won't offer an interpretation. I also think that because you are again repeating what you want
    which again, my code does (as far as the name of the control is concerned). It also does it without all that complicated class stuff - which is not to say it's better, just less complicated. The class version is a great opportunity to learn, that's for sure.
    I'm going to unsubscribe from this thread because I can't seem to get my message across and there's no point in aggravating you further. If you decide you have questions about my procedure, PM me otherwise I won't see your inquiries.
    Good luck with your quest.
    Okay, chalk it up to misunderstanding. Sorry if I overreacted. PM it is, but I'm also replying in the thread for the benefit of others following. Yes, both versions work to provide what I needed, in this specific case, the control's name. Yours inserts a constant, APR's does it with a class, which I need to study a bit more, because I don't fully understand how it works. WithEvents is still a bit of a mystery to me. If the name of the control is changed, the constant needs to be changed as well. The class version does not require a change, but as you point out, is more complex. I would ALSO like to know if it can be done by using a syntax like =RunMouseOver(ControlName) to provide the name of the control AT THE INSTANT THE EVENT IS FIRED, not a constant loaded earlier. The same for things like Tag and ToolTip - they may have changed during runtime, and a pre-loaded constant would not reflect that. The class does, but is more work.

    Your code works. I have said so repeatedly, and I have no problems with it. Thank you once again for supplying it. I am now trying to ALSO learn if there is another way to do it - neither your constants nor APR's class, but a special syntax, or a reserved word, like NAME, that will be evaluated at instant the event fires.

  3. #18
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    pdanes,

    For completeness and for any who may come to this site/thread searching for related info, could you provide sample databases showing the effect you have achieved and the techniques involved. Class module usage examples are not very common. The databases do not have to be extensive nor complete application. I'm thinking you have a requirement that is also not that common, and you have at least 2 solutions, so it could be a very useful reference.
    You may also find that by providing a working example, others may be able to extend the concepts/code involved to "extract" other properties of the controls involved.
    Good luck.

  4. #19
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Yours inserts a constant
    No, it does not. That just convinces me that you don't understand it. There is no constant, and if you change the name of the control, the new name is returned without modifying the code. Not only that, I can retrieve the control tip text with the function. I suppose you could return the value of any property with it, but I don't have the inclination to experiment with it at this point.

  5. #20
    pdanes is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Micron View Post
    No, it does not. That just convinces me that you don't understand it. There is no constant, and if you change the name of the control, the new name is returned without modifying the code. Not only that, I can retrieve the control tip text with the function. I suppose you could return the value of any property with it, but I don't have the inclination to experiment with it at this point.
    Okay, I just put it into a an empty database and tried it, exactly as you said. When I mouse over the control, it works, as you say and as I have repeatedly acknowledged. When I then execute this in the immediate window:

    ?Form_form2.Text8.OnMouseMove

    The result is:

    =MyFunc("Text8")

    How is that not a constant?

  6. #21
    pdanes is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Also, if I change the line

    ctl.OnMouseMove = "=MyFunc(""" & ctl.Name & """)"

    to

    ctl.OnMouseMove = "=MyFunc(""" & ctl.Tag & """)"

    the code continues to display the contents of what Tag contained on initialization. It does NOT reflect subsequent changes, which makes it NOT dynamic.

  7. #22
    pdanes is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by orange View Post
    pdanes,

    For completeness and for any who may come to this site/thread searching for related info, could you provide sample databases showing the effect you have achieved and the techniques involved. Class module usage examples are not very common. The databases do not have to be extensive nor complete application. I'm thinking you have a requirement that is also not that common, and you have at least 2 solutions, so it could be a very useful reference.
    You may also find that by providing a working example, others may be able to extend the concepts/code involved to "extract" other properties of the controls involved.
    Good luck.
    Okay, I've ginned up a simple database with a few textboxes showing what I have figured out so far.
    Attached Files Attached Files

  8. #23
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You still aren't making sense with this "constant" thing. Please look up what a constant is.

    MyFunc is a function with no parameters (which you don't need in this case). What ever you tell it to return in the function code will be returned. The only thing that would be "constant" (which is not the same as A constant) is the value of the property your code tells it to return. If you change the tip text or tag text, the function will return the new value - presumably not until you save your design changes but I've not tested that point.

    What you have discovered by using the immediate window is that the function automatically returns the value of the property you asked for - yet that property value (e.g. the control name) isn't a parameter that is passed to the function. More on that in the last paragraph. So it is dynamic in the sense that if the property value changes, so does the return value of the function. Here's proof where I changed the control name, tip text and tag text between iterations:
    Click image for larger version. 

Name:	txt1.jpg 
Views:	23 
Size:	7.5 KB 
ID:	39883 Click image for larger version. 

Name:	txt11.jpg 
Views:	23 
Size:	8.8 KB 
ID:	39884

    Whatever you did was incorrect or incomplete (e.g. you didn't save between design changes [not convinced that it is necessary but not tested by me] or you moused over 2 different controls between changes, or something else, because the images prove it works)

    What I used to do up to this point is select a bunch of controls and for an event, specify (e.g.) = SomeFunction() and then go to each individual control event and add the control name. That meant having to edit as in = SomeFunction(txtDept) and in another, = SomeFunction(txtCust) etc, etc. I did not see you wanting to do that for 350 controls so I looked found that code (as I stated, it is not original by me).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #24
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    I looked at the database from post #22 and did a little adjusting as per code below. If you know which property values you want to display, you can add them. There may be other and better ways to achieve what you want, but you know your situation and requirement.


    Code:
    Private Sub m_txt_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim strName As String
        Dim sHold As String: sHold = ""
        strName = m_txt.Name
        With m_txt
            If .Tag <> " " Then
                sHold = "_Tag:<" & .Tag & ">"
            End If
            If .ControlTipText <> " " Then
                sHold = sHold & "_ControlTip:<" & .ControlTipText & ">"
            End If
            '
            'You could check for other property values here and append non empty values to sHold
            '
        End With
        m_frm.Controls("Label0").Caption = strName & sHold & " ... X = " & X & " ... Y = " & Y
    End Sub
    Click image for larger version. 

Name:	ControlInfo_viaClassModule.jpg 
Views:	22 
Size:	65.8 KB 
ID:	39885

    I added these lines to the code to show additional properties/values.
    '
    'You could check for other property values here and append non empty values to sHold
    '
    ' eg textbox height and width
    sHold = sHold & "_Height:<" & .Height & ">_Width:<" & .Width & ">"

    Click image for larger version. 

Name:	AddedHeightandWidth.PNG 
Views:	23 
Size:	12.2 KB 
ID:	39886

  10. #25
    pdanes is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by Micron View Post
    You still aren't making sense with this "constant" thing. Please look up what a constant is.

    MyFunc is a function with no parameters (which you don't need in this case). What ever you tell it to return in the function code will be returned. The only thing that would be "constant" (which is not the same as A constant) is the value of the property your code tells it to return. If you change the tip text or tag text, the function will return the new value - presumably not until you save your design changes but I've not tested that point.

    What you have discovered by using the immediate window is that the function automatically returns the value of the property you asked for - yet that property value (e.g. the control name) isn't a parameter that is passed to the function. More on that in the last paragraph. So it is dynamic in the sense that if the property value changes, so does the return value of the function. Here's proof where I changed the control name, tip text and tag text between iterations:
    Click image for larger version. 

Name:	txt1.jpg 
Views:	23 
Size:	7.5 KB 
ID:	39883 Click image for larger version. 

Name:	txt11.jpg 
Views:	23 
Size:	8.8 KB 
ID:	39884

    Whatever you did was incorrect or incomplete (e.g. you didn't save between design changes [not convinced that it is necessary but not tested by me] or you moused over 2 different controls between changes, or something else, because the images prove it works)

    What I used to do up to this point is select a bunch of controls and for an event, specify (e.g.) = SomeFunction() and then go to each individual control event and add the control name. That meant having to edit as in = SomeFunction(txtDept) and in another, = SomeFunction(txtCust) etc, etc. I did not see you wanting to do that for 350 controls so I looked found that code (as I stated, it is not original by me).
    *-I-* am not making any sense?

    What your code creates is this:

    =MyFunc("Text8")

    "Text8" is a constant, passed as a parameter. I can't figure out why you don't understand this. It's an introductory-level concept in every programming course on the planet.

    MyFunc is a function with no parameters
    What?!?!? What do you call strControlName in this definition, if not a parameter?
    Code:
    Public Function MyFunc(strControlName As String)
      MsgBox strControlName
    End Function
    Furthermore, that parameter is exactly what is displayed as the control's name. That same function is called from every box that has this event code attached. Without that parameter, you have nothing.

    If you change the tip text or tag text, the function will return the new value
    No, it will NOT. I knew it wouldn't, but to prevent further accusations by you of shooting from the hip and being wrong about it, I loaded it and tried it, replacing
    Code:
    ctl.OnMouseMove = "=MyFunc(""" & ctl.Name & """)"
    by
    Code:
    ctl.OnMouseMove = "=MyFunc(""" & ctl.Tag & """)"
    since I can't change the NAME of the control at run time. It does exactly what I said – the value of Tag is loaded on initialization (i.e., first MouseMove event., when PassName is called) and that is what stays. Subsequent run-time changes to Tag do NOT show up. NO changes of any sort show up until the form is closed and re-opened, or the PassName routine executed again.

    Here's proof where I changed the control name, tip text and tag text between iterations:
    Yes – between iterations. NOT dynamically, during run-time, while the form remains loaded and opened in Form View. That's what *-I-* wrote, that it has to be renewed for the changes to be displayed. Dynamically means while the form remains open, and these properties are changed in code. Your routine does NOT reflect the current state when a change like that is made, only when the form is unloaded, changed and then activated again. When you do that, PassName runs again on the first instance of a MouseMove event, and the MouseMove event definitions are changed again, and again, to pass a CONSTANT to the MyFunc function.

    You wrote yourself that you didn’t think this up, but copied it from Allen Browne. Nothing wrong with that – he's a great resource, and I've cribbed material from him as well, and learned a great deal from his writings. However, maybe you're not completely clear on what this code is doing. If you can't figure out how to test a RUN-TIME change, let me know, and I will post in this thread a small database that goes through those steps, one at a time, and shows you what is happening in each step.

    What I used to do up to this point is select a bunch of controls and for an event, specify (e.g.) = SomeFunction() and then go to each individual control event and add the control name. That meant having to edit as in = SomeFunction(txtDept) and in another, = SomeFunction(txtCust) etc, etc. I did not see you wanting to do that for 350 controls so I looked found that code (as I stated, it is not original by me).
    Exactly – that is what I was trying to avoid. I have had to do it in the past, and it's a monumental pain in the fundament. Your suggestion does indeed let me avoid such a chore, as does APR's. Both work well, both solve the initial stated problem, and neither addresses the subsequent discussion. However, APR's code does reflect run-time changes.

  11. #26
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    pdanes,

    I recommend you stay on APR's solution. It's the best for your case. It's based on the object oriented programming and gives you the advantage to develop powerful applications with the most less code.
    You will find one more example based on this programming style in the attachment (Appointments.zip) of this topic:
    https://www.accessforums.net/showthr...966#post436966

    But, if you realy have a form with 350 textboxes that the user have to fill in, I will propose an other solution based on simple Access-style methods, with a temporary table as recordsource of a continuous form that reduce enough the controls and the code that you have to manage. The user works in a temporary set of fields and then you can copy these values to the actualy table(s). Also, I suggest using of Enter event instead of MouseMove.
    I don't know if you could apply it in your actualy project but, at least, I hope that will give you some ideas.

    Please, take a look in attachment.

    Cheers,
    John

    P.S. In the code of example from the post 22 (MouseMove.accdb), the procedure
    Code:
    Private Sub Form_Close()
        Set F = Nothing
    End Sub
    should be
    Code:
    Private Sub Form_Close()
        Set C = Nothing
    End Sub
    because the collection -with all instances of ClsTxt-, never terminates.
    Attached Files Attached Files

  12. #27
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    Quote Originally Posted by accesstos View Post
    pdanes,

    I recommend you stay on APR's solution. It's the best for your case. It's based on the object oriented programming and gives you the advantage to develop powerful applications with the most less code.
    You will find one more example based on this programming style in the attachment (Appointments.zip) of this topic:
    https://www.accessforums.net/showthr...966#post436966

    But, if you realy have a form with 350 textboxes that the user have to fill in, I will propose an other solution based on simple Access-style methods, with a temporary table as recordsource of a continuous form that reduce enough the controls and the code that you have to manage. The user works in a temporary set of fields and then you can copy these values to the actualy table(s). Also, I suggest using of Enter event instead of MouseMove.
    I don't know if you could apply it in your actualy project but, at least, I hope that will give you some ideas.

    Please, take a look in attachment.

    Cheers,
    John

    P.S. In the code of example from the post 22 (MouseMove.accdb), the procedure
    Code:
    Private Sub Form_Close()
        Set F = Nothing
    End Sub
    should be
    Code:
    Private Sub Form_Close()
        Set C = Nothing
    End Sub
    because the collection -with all instances of ClsTxt-, never terminates.
    Sorry, it was an oversight on my part.

    The Form3 can be added with another 100 or more text boxes. The code will work, as it stands now for, without any changes.


    Sent from my iPhone using Tapatalk

  13. #28
    pdanes is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by accesstos View Post
    pdanes,

    I recommend you stay on APR's solution. It's the best for your case. It's based on the object oriented programming and gives you the advantage to develop powerful applications with the most less code.
    You will find one more example based on this programming style in the attachment (Appointments.zip) of this topic:
    https://www.accessforums.net/showthr...966#post436966

    But, if you realy have a form with 350 textboxes that the user have to fill in, I will propose an other solution based on simple Access-style methods, with a temporary table as recordsource of a continuous form that reduce enough the controls and the code that you have to manage. The user works in a temporary set of fields and then you can copy these values to the actualy table(s). Also, I suggest using of Enter event instead of MouseMove.
    I don't know if you could apply it in your actualy project but, at least, I hope that will give you some ideas.

    Please, take a look in attachment.

    Cheers,
    John

    P.S. In the code of example from the post 22 (MouseMove.accdb), the procedure
    Code:
    Private Sub Form_Close()
        Set F = Nothing
    End Sub
    should be
    Code:
    Private Sub Form_Close()
        Set C = Nothing
    End Sub
    because the collection -with all instances of ClsTxt-, never terminates.
    Thank you for the suggestion. This form does have that many textboxes - actually, it has almost 700. I had to divide the form into two subforms, because I ran into the maximum limit of controls on a form. However, the users do not fill in 700 textboxes - that would be a zoo. It's a graphic form, representing pieces of storage furniture, with each textbox showing the number of items in a drawer, with its position on the form corresponding to its position in the piece of furniture. The users see quickly which drawers are empty or occupied (empty ones are blank, not zero, and have a different background color from occupied ones), and can click on a drawer to open a popup form showing the contents of the drawer. It's all display-only - none of these textboxes are filled in by the user. They acquire their contents elsewhere in the application.

    The array is fairly dense, and the user may get a bit lost, since the row and column indicators are around the edges. I want to use the MouseMove event to display the row and column in a large font in a separate graphic next to the array, to help the user keep track of where he is. I also have ToolTips on each textbox, but they take a second to popup, and are small. The MouseMove event reacts instantly, and I can make my resulting graphic as prominent as I want, although it is necessarily off to the side a bit.

  14. #29
    pdanes is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Sep 2019
    Posts
    208
    Quote Originally Posted by orange View Post
    I looked at the database from post #22 and did a little adjusting as per code below. If you know which property values you want to display, you can add them. There may be other and better ways to achieve what you want, but you know your situation and requirement.


    Code:
    Private Sub m_txt_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim strName As String
        Dim sHold As String: sHold = ""
        strName = m_txt.Name
        With m_txt
            If .Tag <> " " Then
                sHold = "_Tag:<" & .Tag & ">"
            End If
            If .ControlTipText <> " " Then
                sHold = sHold & "_ControlTip:<" & .ControlTipText & ">"
            End If
            '
            'You could check for other property values here and append non empty values to sHold
            '
        End With
        m_frm.Controls("Label0").Caption = strName & sHold & " ... X = " & X & " ... Y = " & Y
    End Sub
    Click image for larger version. 

Name:	ControlInfo_viaClassModule.jpg 
Views:	22 
Size:	65.8 KB 
ID:	39885

    I added these lines to the code to show additional properties/values.
    '
    'You could check for other property values here and append non empty values to sHold
    '
    ' eg textbox height and width
    sHold = sHold & "_Height:<" & .Height & ">_Width:<" & .Width & ">"

    Click image for larger version. 

Name:	AddedHeightandWidth.PNG 
Views:	23 
Size:	12.2 KB 
ID:	39886
    Yes, there are many things that can be done from here. Both of the early responders provided good solutions - both work, both give me the results I need, and both are a good base that can be expanded to provide a great deal of additional functionality. But neither deals with the question I posed as the last sentence in my original post:
    Is there a way to get the name of the control into the call parameter?
    The parameter NAME is clearly some sort of reserved word in that setting. When specified as a parameter, it passes the name of the parent form to the function called on the MouseMove event. What I am now trying to find out, so far unsuccessfully, is whether there are OTHER reserved words, or some special syntax that lets me pass other values besides the name of the parent form.

    I am NOT looking for alternative ways to accomplish that task. I already have several, and they work well. I am now trying to determine if THAT SPECIFIC THING can be done.

  15. #30
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    ?? I am still confused with your requirement??
    Based on the sample provided by Apr Pillai

    m_txt represents any textbox on your form, m_txt_MouseMove is the mouse movement event on the textbox where the mouse is

    So as Apr Pillai said
    The Form3 can be added with another 100 or more text boxes. The code will work, as it stands now for, without any changes.
    This is interesting
    However, the users do not fill in 700 textboxes - that would be a zoo. It's a graphic form, representing pieces of storage furniture, with each textbox showing the number of items in a drawer, with its position on the form corresponding to its position in the piece of furniture. The users see quickly which drawers are empty or occupied (empty ones are blank, not zero, and have a different background color from occupied ones), and can click on a drawer to open a popup form showing the contents of the drawer. It's all display-only - none of these textboxes are filled in by the user. They acquire their contents elsewhere in the application.
    Do you have a graphic or drawing that shows your proposed interface or design? That may help put things into perspective. Perhaps I'm the only one not following your requirement or the importance of
    "Is there a way to get the name of the control into the call parameter?" - a sample showing your expected interface would help.

    As I see ChrisO's Macbeth seating example(linked in post#4), you could easily have many more textboxes and display info based on MouseMove event.
    Click image for larger version. 

Name:	ChrisO_macbeth.PNG 
Views:	25 
Size:	57.7 KB 
ID:	39888

Page 2 of 5 FirstFirst 12345 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Issues with change event of textbox
    By udigold1 in forum Programming
    Replies: 4
    Last Post: 03-27-2019, 08:39 AM
  2. Query with parameter from Form Textbox
    By Juan4412 in forum Queries
    Replies: 1
    Last Post: 07-10-2013, 02:33 PM
  3. Help with Onclick event to refresh textbox.
    By mikeone610 in forum Access
    Replies: 3
    Last Post: 02-07-2013, 03:58 PM
  4. Replies: 3
    Last Post: 05-07-2012, 12:17 PM
  5. How to call After update event to the textbox
    By pwalter83 in forum Forms
    Replies: 1
    Last Post: 12-20-2011, 11:16 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