PDA

View Full Version : Solved: Access message box



Slowhand
08-09-2004, 02:38 PM
Hi all

:bink: still a novice, please :help

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?

VicRauch
08-09-2004, 04:07 PM
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

Slowhand
08-09-2004, 05:29 PM
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

VicRauch
08-09-2004, 06:12 PM
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

Slowhand
08-10-2004, 12:00 AM
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)

Slowhand
08-10-2004, 12:02 AM
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)

SJ McAbney
08-10-2004, 01:50 AM
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:


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


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

VicRauch
08-10-2004, 06:39 AM
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:

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.

All the above code should be on one line, or multiple lines by using the " & _ " line extender code.

Hope this helps.
Vic

Slowhand
08-10-2004, 01:13 PM
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

Slowhand
08-10-2004, 01:24 PM
PS.
Ive called the secondary form AddNotes

SJ McAbney
08-10-2004, 04:38 PM
Vic, why are you suggesting late binding in this situation?

Slowhand
08-10-2004, 05:22 PM
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.

VicRauch
08-10-2004, 06:57 PM
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.:dunno
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

VicRauch
08-10-2004, 07:02 PM
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

Zack Barresse
08-10-2004, 07:40 PM
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).

Slowhand
08-11-2004, 12:01 AM
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

SJ McAbney
08-11-2004, 02:34 AM
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").

VicRauch
08-11-2004, 06:27 AM
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.


'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



Hope that helps finish up this project.

Vic

Slowhand
08-11-2004, 10:30 AM
:ole:

Many thanks Vic

works a treat
:bigdance2

Nick