473,386 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Input Box for comments in Microsoft Access

Hi,

I have a database in Access that currently holds the status of a salesperson and the comments of the status. The comment is an open-ended field typed in by a user.

For example, if Jonny has the status of "On Leave" then the comment might say "26-11-09: Johnny is currently on medical leave and will return by 01-12-09". The comment is a compiled overtime and stored in a Text box.

However, my problem is that, when i transfer this column called "Comments" into excel, it populate all the comments into one single field. Thus the field in excel becomes very large and hideous.

So the solution i had was to create an input box.
Expand|Select|Wrap|Line Numbers
  1. Sub UserInput()
  2.  
  3. Dim iReply As Integer
  4.  
  5.     iReply = MsgBox(Prompt:="Please insert the latest comment", _
  6.  
  7.             Buttons:=vbYesNoCancel, Title:="Insert Comment")          
  8.  
  9.     If iReply = vbYes Then
  10.  
  11.         'Insert comment into TextBox as "Latest Comment" Then push previous    comment into another field
  12.  
  13.     ElseIf iReply = vbNo Then
  14.  
  15.        'Do Other Stuff
  16.  
  17.     Else 'They cancelled (VbCancel)
  18.  
  19.         Exit Sub
  20.  
  21.     End If
  22.  
  23. End Sub
The purpose of my soultion is to always save the last comment that the user types in into another textbox. So that if i export the "Comment" into excel, it will only show me the lastest comment. And if the user puts in a new comment, the previous comment will be saved in another textbox, or alternatively an array?

For now, i can only create the Input Box but i cannot do the function that allows me to save previous comments and only extract the latest comment into excel. Hopefully i can get some advice(:

Many thanks in advance for all the help!!
Nicole
Nov 26 '09 #1
4 6802
ADezii
8,834 Expert 8TB
Hello Nicole, I not exactly clear as to what you are trying to accomplish, so I wrote a generic code Template that will hopefully point you in the right direction. First, a couple of simple assumptions:
  1. You have a Text Box on your Form named txtLastComment which will always contain the Last Comment entered by the User.
  2. You have 9 Text Boxes on your Form named Text1, Text2, ...Text9, which will contain all previously entered Comments up to a MAXIMUM of 10. Prior Comments will be 'Pushed' into this Text Boxes when additional ones are added.
  3. The User will be prompted for a Comment, which if it is a legitimate value, be placed into txtLastComment. If a prior Comment exists, it will be 'Pushed' into the next available Text Box.
  4. The code is not complete since you will need a mechanism to Clear the Text Boxes, and also to Reset the intCommentNumber to 0.
  5. Any questions, please feel free to ask.
    Expand|Select|Wrap|Line Numbers
    1. Dim strComment As String
    2. Static intCommentNumber As Integer
    3.  
    4. 'Prompt the User to enter a Comment
    5. strComment = InputBox$("Please insert the latest Comment", "Insert Comment")
    6.  
    7. 'If the User enters nothing or Cancels, get outta there!
    8. If strComment = "" Then Exit Sub
    9.  
    10. If intCommentNumber = 10 Then   'Has the MAX been reached
    11.   MsgBox "Yoou have reached the MAXIMUM Number of Comments!"
    12.     Exit Sub
    13. End If
    14.  
    15. intCommentNumber = intCommentNumber + 1     'Increment Comment Counter
    16.  
    17. If intCommentNumber = 1 Then        '1st Comment, nothing to Push
    18.   Me.Controls("txtLastComment") = strComment
    19. Else        'Push the Comment in txtLastComment to the next available Text Box
    20.   Me.Controls("Text" & CStr(intCommentNumber - 1)) = Me.Controls("txtLastComment")
    21.  
    22.   'Place most recent Comment in txtLastComment
    23.   Me.Controls("txtLastComment") = strComment
    24. End If
  6. This can also be accomplished using a Static Array with Redim Preserve to store the previous Comments, but would be more difficult.
  7. Just for curiosity, what are you doing with the Prior Comments
Nov 26 '09 #2
Thanks ADezill for your help!

Regarding your last quesiton (Question 7), i would want to keep the prior comments in a Memo Field preferably as I need it for record keeping, however the purpose of this is to separate the latest comment input by the user so as to allow the latest comment only to be exported into excel.

I have tried to export the whole textbox as a whole, however because excel has the 255 character limit, not all of my comments can be seen. Thus to avoid this i have to split the comments up.

So when the user first input a comment it is stored in the "Last Comment" box. And when exporting this into excel i have no problem. But later, after a few weeks of comments being added the problem arises. when i export i cannot view all of the comments i've written. Hence the need for this solution.

The last comment to always be saved in the "Last Comment" box and if a new comment comes in the previous comment in the last comment box goest into a memo field text box for record keeping sake. this memo field box will not be exported into excel but just kept. If the user wishes to see this last comment, they can do so by using the database directly.

I hope i don't confuse you as your help is greatly appreicated! many thanks in advance!! and if you have any questions please ask(:

Cheers mate,
Nicole
Jan 27 '10 #3
ADezii
8,834 Expert 8TB
  1. If you insist on storing all Comments in a MEMO Field, then you can separate each Comment by a Carriage Return/Line Feed (either {ENTER} or {CTRL}{ENTER} depending on the ENTER Key behavior) which will result in each Comment being in its own Line progressing vertically
  2. The Last Comment entered will always be the Last Line in the Memo Field.
  3. You can now place each Comment in the Memo Field into an Array using Split(), then extract the Last Comment easily since it is located at the Upper Bound of the Array.
  4. Hopefully this makes sense to you. I'll post the code assuming the MEMO Field is named [Comments], and if you have any questions, feel free to ask.
  5. I'm sure other suggestions will come along, but since you wish to use a MEMO Field to store all Comments, they will probably be limited.
    Expand|Select|Wrap|Line Numbers
    1. Dim varComments As Variant
    2. If IsNull(Me![Comments]) Then Exit Sub
    3.  
    4. 'Last Comment entered will be the Highest Index in the Array
    5. varComments = Split(Me![Comments], vbCrLf)
    6.  
    7. MsgBox varComments(UBound(varComments))        'Last Comment
    8.  
  6. To 'Push' a New Comment to the bottom of the MEMO Field (Stack):
    Expand|Select|Wrap|Line Numbers
    1. Me![Comments] = Me![Comments] & vbCrLf & "New Comment"
Jan 27 '10 #4
This is the kind of thing I try to teach people. Can I count on a sequel?
Oct 27 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Emanuel Marciniak | last post by:
Hi all, We have the form which uses checkboxes for several fields and the target action points to outside webservice. Unfortunatelly they do not support checkboxes. How to pass it as a radio...
13
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices...
7
by: F. Michael Miller | last post by:
I have a db with Access front end, sql back, linked tables. I need to be able to change input masks at the table level in code. Any ideas? Thanks!
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
8
by: David Cameron | last post by:
I noticed that using an HTMLInputRadioButton and specifying a value to be an empty string (""), this is overridden by ASP.Net which set the value of the control to be the same as the ID of the...
1
by: Alfred Salton | last post by:
Can anyone point to an example that uses a dataset as the input parameter to a web service? Can an XMLDataDocument be used as in input parameter to the web service? Incoming data in my...
2
by: Incolor | last post by:
Hello All! I have to generate a checklist form as an input form in Access. A paper form is taken out in the field and checked yes, no, OR n/a for each item inspected. The problem I am having is...
3
by: adham | last post by:
Hey there, I am creating an access database which stores information on websites, and i would like to create table that displays the interest flags. Basically i want to create a 5 X 9 table with...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
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
0
BarryA
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...
1
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.