473,799 Members | 3,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Input Box for comments in Microsoft Access

23 New Member
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 6842
ADezii
8,834 Recognized Expert Expert
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 intCommentNumbe r 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
nicolenwn
23 New Member
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 Recognized Expert Expert
  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
2507
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 buttons or pull down select box with Yes/No options for example (which they support) using still checkboxes as an input entry. Thank you for any hint, emanuel
13
11440
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 Restaurant" etc. automatically and programmatically during data entry? This would eliminate my concatinated strings from producing errors when I base the string on a query. Think this is an example of the "Dreaded Apostrophe Bug." If I enter a...
7
7075
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
4781
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 button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
8
5906
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 control. See the code below * Page.aspx: <%@ Page language="c#" Codebehind="Test.aspx.cs" AutoEventWireup="false" Inherits="Webspace.Test" %>
1
3787
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 application needs to be stored in SQL or as XML file, depending on the method invoked.
2
4465
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 this, the form should have a main heading with the date, report no, and inspector. This information should be entered only once in the form, but recorded for each item inspected in the database table. Under the main heading there is another...
3
2311
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 both text, and a yes/no field. For example if the website is about cars, i would check the tick box in the car box. Im sure you can visualise a 2d table with different interests in each box, which includes a tick box. Now i want to include the...
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.