Consulting

Results 1 to 19 of 19

Thread: Solved: Access message box

  1. #1
    VBAX Regular Slowhand's Avatar
    Joined
    Aug 2004
    Location
    Blackpool UK
    Posts
    15
    Location

    Solved: Access message box

    Hi all

    still a novice, please

    I have built a database at work and have a memo field which i would like to be able to add to without actually being able to type directly into it - I have seen somewhere a box that pops up when you click on an add notes button, where you then type the notes required and when you then submit the notes it adds a date stamp can anybody explain how I need to go about producing this?

  2. #2
    VBAX Regular
    Joined
    Aug 2004
    Location
    Sacramento, CA
    Posts
    13
    Location
    Dear Slowhand,

    I can quickly think of three different ways to do what you want. The last way is the one I consider the best.
    1. Use the function Inputbox(). This function gives you a few options and will return whatever the user types as the return from the function. You will need to set (make equal) the function to a variable or the field name you want the memo to be put into. The code would look something like this:
    fieldName = InputBox("Enter memo")
    You have several more parameters you can use here too.
    2. Access allows you to use a "Zoom Box" which you get to with Shift/F2. From a text box you press the Shift key and the F2 key which will give you the Zoom box. Anything you type into the Zoom box will be returned and inserted into the text box you started from.
    3. Create a form with a large text field on it, then open your new form when the user wants/needs to enter the memo data.

    Yes, I understand you are new at this, and so if you want more info, just ask for help with the method you would like to try.

    Vic

  3. #3
    VBAX Regular Slowhand's Avatar
    Joined
    Aug 2004
    Location
    Blackpool UK
    Posts
    15
    Location
    Hi Vic - many thanks for your quick reply

    Can any of these stop people from typing directly into the memo field? and can any of them automatically insert the date() stamp this is the most important part
    If you want your Dreams to come true, Don't over sleep

    Nick

  4. #4
    VBAX Regular
    Joined
    Aug 2004
    Location
    Sacramento, CA
    Posts
    13
    Location

    Use option 3, your own form

    If you create your own form, then you will have control of the date() stamp, etc. If you make the memo field Enabled=True, Locked=True, then no one can type into the memo field. Using the "On Enter" event, open your created form. Within your created form, fill the "memo" field by referencing the memo field in your original form. When the user is finished entering the data they need to enter, they can click the "Continue" (or "Update" or ????) button. You need to have the code behind that button take what the user entered, update the memo field in the original form, update the date() stamp, unless you are adding that to the memo field itself, then do the date() stamp BEFORE you update the original form. The last thing you want to happen after pressing the "Continue" button, is to close the memo entry form. One other thing, I would suggest you open the memo entry form as a pop-up, modal form. That way, the user has to deal with the memo field before moving on.

    Hope this helps.

    If you want to see a sample database I have done, you can look me up in the user area, then go to my web site.

    Vic




    Hi Vic - many thanks for your quick reply

    Can any of these stop people from typing directly into the memo field? and can any of them automatically insert the date() stamp this is the most important part
    __________________
    If you want your Dreams to come true, Don't over sleep

  5. #5
    VBAX Regular Slowhand's Avatar
    Joined
    Aug 2004
    Location
    Blackpool UK
    Posts
    15
    Location
    Again many thanks for your help

    I have figured out the pop up form, but am struggling with the update command button.

    What I am trying for is to have the date stamp and user name (if poss) then the updated info so it would look something like

    End of last update message
    8/8/4 Nick Davis:
    start of new info

    The dbase users will be on a logged onto network (although the dbase is not password protected)
    If you want your Dreams to come true, Don't over sleep

    Nick

  6. #6
    VBAX Regular Slowhand's Avatar
    Joined
    Aug 2004
    Location
    Blackpool UK
    Posts
    15
    Location
    Hi Vic

    Again many thanks for your help

    I have figured out the pop up form, but am struggling with the update command button.

    What I am trying for is to have the date stamp and user name (if poss) then the updated info so it would look something like

    End of last update message
    8/8/4 Nick Davis:
    start of new info

    The dbase users will be on a logged onto network (although the dbase is not password protected)
    If you want your Dreams to come true, Don't over sleep

    Nick

  7. #7
    VBAX Tutor SJ McAbney's Avatar
    Joined
    May 2004
    Location
    Glasgow
    Posts
    243
    Location
    The form should be bound to a query based on the table where you will store the date updated and the memo. I'll suppose the fields are called Comments, UserName and LastUpdated.

    The textbox that displays the memo (supposed as txtComments) will be bound to the Comments field; a textbox called txtLastUpdated will be bound to the LastUpdated field. Also, a third textbox called txtUserName. These are both bound in the textboxes' ControlSource property.

    Finally, in the form's BeforeUpdate event, we put the latest time in the LastUpdated field:

    [vba]
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me.txtLastUpdated = Now
    Me.txtUserName = Environ("username")
    End Sub
    [/vba]

    Is this the only form in your database? It certainly sounds so.

  8. #8
    VBAX Regular
    Joined
    Aug 2004
    Location
    Sacramento, CA
    Posts
    13
    Location
    From Nick:
    What I am trying for is to have the date stamp and user name (if poss) then the updated info so it would look something like

    End of last update message
    8/8/4 Nick Davis:
    start of new info

    The dbase users will be on a logged onto network (although the dbase is not password protected)

    Nick,
    As I understand your situation, you do not want to bind your memo field to any form where the users can update the existing memo field. Therefore, you really can't bind the pop-up form to any query. I think I had already had you reference the memo field from the pop-up form back to the original form. My further thinking is that you will only want the users to be able to see, but not directly update that memo field. Which means you show that field on the pop-up form, AND give the users a blank text box to use to add their current comment(s) to. Then, when they are finished, and click the command button, that button would do the following:
    [VBA]
    Forms!frmOriginal!txtMemoField =
    Forms!frmOriginal!txtMemoField 'start with existing data
    & vbCrLf 'Move to new line
    & Date() & " " & txtUserName 'Add Date and User
    & vbCrLf 'Move to new line
    & me!txtNewMemoData 'Add new memo info.
    [/VBA]
    All the above code should be on one line, or multiple lines by using the " & _ " line extender code.

    Hope this helps.
    Vic
    Last edited by VicRauch; 08-10-2004 at 12:23 PM. Reason: Left Slowhand words in start of my message

  9. #9
    VBAX Regular Slowhand's Avatar
    Joined
    Aug 2004
    Location
    Blackpool UK
    Posts
    15
    Location
    Hi Vic

    I have what you said

    Form!Problems!Updates = Forms!Problems!Updates & vbCrLf & Date & " " & txtUserName & vbCrLf & Me!Updates


    on one line, the problem seems that it does not recognise the field I get an error message:
    Cannot find Updates field

    My main form is called Problems, the memo field is called Updates
    not sure where i am going wrong
    If you want your Dreams to come true, Don't over sleep

    Nick

  10. #10
    VBAX Regular Slowhand's Avatar
    Joined
    Aug 2004
    Location
    Blackpool UK
    Posts
    15
    Location
    PS.
    Ive called the secondary form AddNotes
    If you want your Dreams to come true, Don't over sleep

    Nick

  11. #11
    VBAX Tutor SJ McAbney's Avatar
    Joined
    May 2004
    Location
    Glasgow
    Posts
    243
    Location
    Vic, why are you suggesting late binding in this situation?

  12. #12
    VBAX Regular Slowhand's Avatar
    Joined
    Aug 2004
    Location
    Blackpool UK
    Posts
    15
    Location
    Hi vic

    Sorry I don't understand, What is late binding?

    - truly I have absolutely no idea when it comes to Vb or macros in access -

    Unfortunately I cannot post a copy of the dbase, as I work within a government agency and there is data already in place.
    If you want your Dreams to come true, Don't over sleep

    Nick

  13. #13
    VBAX Regular
    Joined
    Aug 2004
    Location
    Sacramento, CA
    Posts
    13
    Location
    Nick,
    My first idea is that on the pop-up form, you might have spelled the Updates field differently than on the Problems form. It might be Update (without the "s") or whatever. Trust me, you have something misspelled somewhere.
    I've done it too many times. Let me know it that doesn't work, and we'll see if something else comes to mind.

    Vic

  14. #14
    VBAX Regular
    Joined
    Aug 2004
    Location
    Sacramento, CA
    Posts
    13
    Location
    Abulafia,

    Late binding: Nick said he did not want the users to be able to get into the memo field and make any changes. I understood that to mean he only wanted to let them add notes, not change anything. Plus, as notes are added, he wanted the date and user appended to the added note. Therefore, there was no way to give the user the current memo field, only a copy of it that they could not change. By having the real (current) memo field display (but locked) on the form, that let them be able to read it, and then make their addition to it using the pop-up form.

    I hope that explains what I am understanding of Nick's situation.

    Vic

  15. #15
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by Slowhand
    Hi vic

    Sorry I don't understand, What is late binding?...

    Late binding (vs. Early binding) is where you reference an Object Reference (or Scripting runtime, etc) to use various other aspects in your code (e.g. creating an instance of another application, Excel, Outlook, etc). But the key point is it's in your code. Early binding is generally (I say that loosley) a more accepted practice and requires the user (on each pc) to reference the specific Library Reference called from the code, and enabled before the code is compiled. This will (should) allow your code to run quicker and smoother when running between apps.

    There are occasions when using Late Binding has it's advantages. For other people at my work, any kind of help I give them, I always use Late Binding. I don't want to go into everybody's pc and enable all the references they need. I just use Late Binding in my code and distribute freely. So they both have their places.

    I hope that helps a little bit. I'm sure there are a lot better explanations out there than me (and more of a leading expert than myself).

  16. #16
    VBAX Regular Slowhand's Avatar
    Joined
    Aug 2004
    Location
    Blackpool UK
    Posts
    15
    Location
    My Thanks to you Vic
    What I had missed was adding the field for the add Notes to the Dbase (told you I was Thick) it now works a treat.

    Can I ask how do I add to the AddNotes form an open clean and close command
    If you want your Dreams to come true, Don't over sleep

    Nick

  17. #17
    VBAX Tutor SJ McAbney's Avatar
    Joined
    May 2004
    Location
    Glasgow
    Posts
    243
    Location
    Quote Originally Posted by VicRauch
    Late binding: Nick said he did not want the users to be able to get into the memo field and make any changes. I understood that to mean he only wanted to let them add notes, not change anything.
    Nothing to do with the problem. I was referring to your use of Me! instea dof Me. which would be more favourable.

    Also, Forms!MyForm!MyControl which can be written as Forms("MyForm")("MyControl").

  18. #18
    VBAX Regular
    Joined
    Aug 2004
    Location
    Sacramento, CA
    Posts
    13
    Location
    Nick,
    I'm not sure why you would have to add the field AddNotes to your database, unless the pop-up form has a RecordSource as the table you are adding these notes (memo) to. But, from this distance (me to where ever you are) I don't really want you to change anything if it is working now.

    Clean open and close commands: Your form should open when your user either gets into the memo field on your Original form (using the OnEntry event) or when you have them click a button to add to the memo field. And the close command would be the last thing that happens after clicking a button on the pop-up form that adds their added comment to the original memo field.

    [VBA]
    'From within the "OnEntry" event of the original memo field
    ' to open the Pop-Up form.
    DoCmd.OpenForm "frmPopUp", , , , , acDialog


    'From the "OnClick" event of the "Close" command button of
    ' the Pop-Up form.
    DoCmd.Close acForm, Me.Name

    [/VBA]

    Hope that helps finish up this project.

    Vic

  19. #19
    VBAX Regular Slowhand's Avatar
    Joined
    Aug 2004
    Location
    Blackpool UK
    Posts
    15
    Location


    Many thanks Vic

    works a treat


    Nick
    If you want your Dreams to come true, Don't over sleep

    Nick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •