I'm trying to setup an input box that will force the users of an Access DB to enter a (mandatory) comment before they update certain fields. The built-in 'InputBox' function only allows one line of 256 characters to be entered.
I'm looking for a larger, multiline textbox.
After some searching I came across this post:
http://www.dbforums.com/showthread.php?1675385-Make-input-form-bigger-to-allow-for-multi-line-text
This seems to do exactly what I want except for the fact it doesn't work... The problem: after adding all the code and looking for the post for additional instructions, I weeded out all error messages, but there is no pop-up box appearing.
My questions:
1) is anyone here familiar with the approach in the post I linked to? Or perhaps with this very code? If so, can you confirm this still works with access 2010?
2) Perhaps I'm making this too complicated and is there a better way to accomplish an improved / extended version of the default 'InputBox'
I have added a DB of the code to this post, exactly as copied from the instructions in the link.
I agree with Seth, there is no need to create a class and deal with properties.
To expand on what Seth has detailed, here is some code I copy and pasted together to accomplish what he's laid out. It allows you to supply the Prompt, Title and a Default Value for the TextBox: - ' Placed in a module
-
Public gMultiLineInputBoxPrompt As String
-
Public gMultiLineInputBoxTitle As String
-
Public gMultiLineInputBoxValue As String
-
-
Public Function MultiLineInputBox(ByRef sPrompt As String, Optional sTitle As String = "MS Access", Optional sDefault As String = "")
-
gMultiLineInputBoxPrompt = sPrompt
-
gMultiLineInputBoxTitle = sTitle
-
gMultiLineInputBoxValue = sDefault
-
DoCmd.OpenForm FormName:="frmInputForm", WindowMode:=acDialog
-
MultiLineInputBox = gMultiLineInputBoxValue
-
End Function
- ' Placed in a Form
-
Private Sub cmdCancel_Click()
-
gMultiLineInputBoxValue = ""
-
Docmd.Close
-
End Sub
-
-
Private Sub cmdOK_Click()
-
gMultiLineInputBoxValue = Me.txtInput.Value
-
Docmd.Close
-
End Sub
-
-
Private Sub Form_Load()
-
Me.Caption = gMultiLineInputBoxTitle
-
Me.lblInput.Caption = gMultiLineInputBoxPrompt
-
Me.txtInput.Value = gMultiLineInputBoxValue
-
End Sub
Usage: - SomeVariable = MultiLineInputBox("What is your favorite color?", , "Red")
The trick really is to set the EnterKeyBehaviour Property of the TextBox to "New Line in Field", otherwise the Enter Key will move out of the TextBox and not create a new line.
4 1487
That is a very complicated way of doing things. All you need to do is create a form with the controls that you want. Then set the form's Modal and Pop Up properties to Yes. Create a global variable that will store the value that you enter. To open this form, use the following code: - DoCmd.OpenForm FormName:="frmInputForm", WindowMode:=acDialog
In your form's OK button, assign the value that you have entered to the global variable and then close the form. Once the form has closed, then your code resumes at the next line after the line that opened the form. You can now reference your global variable to get the data that you entered.
One of the reasons this appealed to me, is that you can customize the Form each time you instantiate it. I have to use this popup for multiple fields.
If I understand your solution correctly, I would have to make a specific form for each situation, or precede each popup form with a popup message explaining to the user what to fill out.
I agree with Seth, there is no need to create a class and deal with properties.
To expand on what Seth has detailed, here is some code I copy and pasted together to accomplish what he's laid out. It allows you to supply the Prompt, Title and a Default Value for the TextBox: - ' Placed in a module
-
Public gMultiLineInputBoxPrompt As String
-
Public gMultiLineInputBoxTitle As String
-
Public gMultiLineInputBoxValue As String
-
-
Public Function MultiLineInputBox(ByRef sPrompt As String, Optional sTitle As String = "MS Access", Optional sDefault As String = "")
-
gMultiLineInputBoxPrompt = sPrompt
-
gMultiLineInputBoxTitle = sTitle
-
gMultiLineInputBoxValue = sDefault
-
DoCmd.OpenForm FormName:="frmInputForm", WindowMode:=acDialog
-
MultiLineInputBox = gMultiLineInputBoxValue
-
End Function
- ' Placed in a Form
-
Private Sub cmdCancel_Click()
-
gMultiLineInputBoxValue = ""
-
Docmd.Close
-
End Sub
-
-
Private Sub cmdOK_Click()
-
gMultiLineInputBoxValue = Me.txtInput.Value
-
Docmd.Close
-
End Sub
-
-
Private Sub Form_Load()
-
Me.Caption = gMultiLineInputBoxTitle
-
Me.lblInput.Caption = gMultiLineInputBoxPrompt
-
Me.txtInput.Value = gMultiLineInputBoxValue
-
End Sub
Usage: - SomeVariable = MultiLineInputBox("What is your favorite color?", , "Red")
The trick really is to set the EnterKeyBehaviour Property of the TextBox to "New Line in Field", otherwise the Enter Key will move out of the TextBox and not create a new line.
Seth, Jforbes,
Thanks both for your quick and accurate replies. With Jforbes addition, this will work for me!
In my implementation I made a small change: instead of using global variables I added the necessary variables to my collection of TempVars.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: hokiegal99 |
last post by:
I don't understand how to use a loop to keep track of user input. Could
someone show me how to do what the program below does with a loop?
Thnaks!
----------------------------
#Write a...
|
by: Paulers |
last post by:
hello VB masters I have an issue that I am hoping you can help me with.
I am creating an application that accepts user input via a richtextbox.
the user can enter multiple entries and I need to...
|
by: evilmonkey |
last post by:
I am very new to programming as well as Java and this is my first post so please forgive me if this is not quite posted correctly. My Problem is that I have only been using scanner to get user input...
|
by: oozy |
last post by:
Hi,
I'm currently using
Page.Form.DefaultButton = ChangePassword1.FindControl("xx").UniqueID
to set my DefaultButtons in a form that has multiple wizards(each in
it's own panel). I can...
|
by: bob1660 |
last post by:
I am new to PHP and MYSQL. I have a Database table with 4 field. FirstName, LastName, DateofBirth and MemberNumber. I would like to have a form where a user can fill in the FirstName, LastName and...
|
by: =?Utf-8?B?TmFt?= |
last post by:
Using Response.Redirect(“error.htm”) in the catch block of a try-catch
statement, I am redirecting a page to a generic page if an error occurs in
code-behind of the page.
Since...
|
by: Steve Swift |
last post by:
I have a page that accepts user input, including HTML. I would like to
offer a preview of what the users HTML will look like, but I'd also like
to avoid having to parse their HTML to ensure that it...
|
by: topher23 |
last post by:
I've seen a lot of questions about how to make secure database passwords. I'm going to go over a method of encrypting a password using the MD5 encryption algorithm for maximum security.
First,...
|
by: Melanie Kremer |
last post by:
I have a report where the RecordSource is set based on user selections in several combo boxes. When I attempt to add print functionality, I can either print the report with the full RecordSource...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |