Solved Open a form in dialog mode by clicking on the text of a textbox (1 Viewer)

zelarra821

Registered User.
Local time
Today, 21:50
Joined
Jan 14, 2019
Messages
813
Well, as the title says, I want to open a form in dialog mode by clicking on a textbox, on the text. I have tried this

Code:
Private Sub TextoLargo_Click()
    DoCmd.OpenForm "FTextosLargosSingeForm", acNormal, , , , acDialog
End Sub

Thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:50
Joined
Oct 29, 2018
Messages
21,496
I tried this:
Code:
Private Sub Text34_Click()
DoCmd.OpenForm "form9", , , , , acDialog

End Sub
 

zelarra821

Registered User.
Local time
Today, 21:50
Joined
Jan 14, 2019
Messages
813
It doesn't work. I have to tried the other solution.
 

zelarra821

Registered User.
Local time
Today, 21:50
Joined
Jan 14, 2019
Messages
813
Private Sub Text34_Click() DoCmd.OpenForm "form9", , , , , acDialog End Sub
I have tried this, but it doen't work. You can see the database.
 

Attachments

  • Database.accdb
    1.4 MB · Views: 68

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:50
Joined
Feb 19, 2002
Messages
43,365
I have no idea where theDBGuy was going with his suggestion. It is identical to what you are doing except it uses bogus names.

form1 works for me. My definition of "works" is - the code in the click event opens a different form. It doesn't open it to the correct record but who would know that if every record is identical?

We have no idea what your objective is. Are you trying to open the second form to a specific record? If so, do yourself a favor and make each row in your test data different so you will recognize that a different record is being opened or is not being opened. Then you can tell us. The Open code always opens to the "first" record. It doesn't open the record I clicked on. Now that's a problem definition that I can give you the answer for.

Start by using help or at least intellisense. As you type the DoCmd to open the form, you will see that there is an optional WHERE argument. WOW!!! you mean I can filter the form as it opens? Why, yes you can.

Code:
Private Sub TextoLargo_Click()
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenForm "FTextosLargosSingeForm", , , "ID = " & Me.ID, , acDialog
    Me.TextoLargo.Repaint
End Sub
 

zelarra821

Registered User.
Local time
Today, 21:50
Joined
Jan 14, 2019
Messages
813
I have no idea where theDBGuy was going with his suggestion. It is identical to what you are doing except it uses bogus names.

form1 works for me. My definition of "works" is - the code in the click event opens a different form. It doesn't open it to the correct record but who would know that if every record is identical?

We have no idea what your objective is. Are you trying to open the second form to a specific record? If so, do yourself a favor and make each row in your test data different so you will recognize that a different record is being opened or is not being opened. Then you can tell us. The Open code always opens to the "first" record. It doesn't open the record I clicked on. Now that's a problem definition that I can give you the answer for.

Start by using help or at least intellisense. As you type the DoCmd to open the form, you will see that there is an optional WHERE argument. WOW!!! you mean I can filter the form as it opens? Why, yes you can.

Code:
Private Sub TextoLargo_Click()
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenForm "FTextosLargosSingeForm", , , "ID = " & Me.ID, , acDialog
    Me.TextoLargo.Repaint
End Sub
Yes, @Pat Hartman , you are right in everything you say. I was looking to open the textbox I click on in a window, but I needed to add the Where clause. I just wanted to first test how the form opened and then add the Where clause.

My problem has been that, I don't know why, the design view is activated in VBA and I can't deactivate it. I get a message saying "Macros for this project are disabled. Please see the online Help or see the Host application's documentation to determine how to enable macros." I have to say that I already have all the macros enabled in the Trust Center. In fact, if you go to the file that I have uploaded, you will see that it does not work when you click because the design is enabled and it cannot be disabled. Does anyone know why this happens? Thank you very much.
 

Cronk

Registered User.
Local time
Tomorrow, 05:50
Joined
Jul 4, 2013
Messages
2,772
Why would you want to pull up the same message box every time anyone clicks in that text box?
 

zelarra821

Registered User.
Local time
Today, 21:50
Joined
Jan 14, 2019
Messages
813
I don't know which message box you mean. I will answer what I have understood. I want to open a dialog form when clicking on a record so I can scroll the text box with the mouse wheel. It is one of the solutions that fiverr has proposed to me to scroll inside a text box, because in a continuous form you cannot
 

Cronk

Registered User.
Local time
Tomorrow, 05:50
Joined
Jul 4, 2013
Messages
2,772
Sorry. What I meant was
Why would you want to pull up the same dialog form with the same message every time anyone clicks in that text box?
 

zelarra821

Registered User.
Local time
Today, 21:50
Joined
Jan 14, 2019
Messages
813
I put the reason above. I searched the internet for how to scroll with the mouse wheel in a textbox. I found several methods, three in particular, but what was my surprise that it worked in a single form, but not in a continuous one. I asked here for a solution but no one knew how to tell me anything, so I asked on Fiverr, and one told me to create a form in dialog mode that opens the textbox you click on, so you can scroll with the mouse wheel and see the content better than with the scroll bar. My fault was not sending the OpenForm code with the Where clause, which could cause trouble, but I've already solved it and it works perfectly for me. It didn't work for me before because I had macros disabled, and it was necessary to unlock the document in the properties, which you access through File Explorer.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:50
Joined
Feb 19, 2002
Messages
43,365
I would get rid of all the mouse wheel code. Scrolling happens naturally in current versions of Access.

And please think about what we could possibly figure out from "doesn't work". I figured out that you hadn't included the where argument but I had no shot at figuring out that you had macros disabled since nothing about "doesn't work" indicated that might be your problem.
 

zelarra821

Registered User.
Local time
Today, 21:50
Joined
Jan 14, 2019
Messages
813
Hello, thanks for answering. First of all, I just tried removing the code and it does work without adding any code. Thanks a lot.

Second, apologize. I also didn't know it didn't work because of that. I found out researching, that's why I put here what had happened and how it was solved, in case it happens to someone else.
 

Users who are viewing this thread

Top Bottom