Reusable Popup form to edit memo fields

Danick

Registered User.
Local time
Yesterday, 23:01
Joined
Sep 23, 2008
Messages
371
I have a form with a few memo fields. The form is not big enough to allow users to edit these memo fields very well. So I created a new form with just one big text box and have the form pop up when the user double clicks one of the memo fields from the previous form. Looks like this:

stDocName = "frmInputMemo1"
stLinkCriteria = "[AfieldID]=" & Me![AfieldID]
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria

The popup form "frmInputMemo1" is bound to the table and field that the user wanted to edit.
This works, but just for that one memo field. I would have to create more popup forms to allow the same for the other memo fields.

How can I do this same thing but reuse the same popup form for all the memo fields.
 
Last edited:
Why not use this instead:

DoCmd.RunCommand acCmdZoomBox

and then you don't need the extra form. Just put it either in the text box's Got Focus event or have a button to call it. If you use the button you would need to include:
Code:
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdZoomBox
 
The single line

DoCmd.RunCommand acCmdZoomBox

also works well in the Double-Click event of the Textbox. It
  • Avoids an extra Command Button
  • Works in all Form Views, including Datasheet, which doesn't allow buttons
  • Only expands the Textbox if the user wants it to, not every time you Tab thru the Control.
Linq ;0)>
 
I don't like the way DoCmd.RunCommand acCmdZoomBox works or looks.
I should have stated that I tried this already and was not satisfied with it.
For one thing, hitting the ENTER button closes the form. And I can't find any way to format the size I want.

I did some searching and found a post that will do exactly what I want. But I can't figure out how to make it work for me. I don't have enough posts on the forum to post the link, but here is the summary of it. It's post 180861.


There a couple of things I'm having trouble understanding in this post.

1) How do you create public string variables in a standard module called StrZoomText, StrZoomControl & StrOpenForm

2) How do I modify these controls to work with my form
StrZoomText = Me.ActiveControl
StrZoomControl = Me.ActiveControl.Name
StrOpenForm = Me.Name
DoCmd.OpenForm "FrmZoomForm"



OK - Never mind - After a few attempts I finally got this thing to work.
Thanks for all your help.
Now I will probably have to figure out how to make this work with a SubForm in the same way the previous poster linehand did.

And thanks to apr_pillai for an amazing look at an amazing way to this same thing. I couldn't get it to work with my double click form and I really didn't want to get into custom menus.

Have a great day!!
 
Last edited:
Pass the full reference to the field or control to the form via OpenArgs. OpenArgs is an argument in the OpenForm method. See this:



OK - I tried your OpenArgs method and I can get the form to popup and show the info. But it seems to only be for viewing. I can not get it to store and of the edits I make in the expanded form.
 
You tried the OpenArgs by doing what? Show us what you did.
 
You tried the OpenArgs by doing what? Show us what you did.

I did exactly what is on the web site and I was able to get the form to popup and populate the fields. But when I tried to edit the field, the new information would not get passed back to the other form. I tried on the sample database as well and it works the same way so I am pretty sure I did it correctly.

I did find my solution in another tread called "Builiding a custom Zoom Box to display a large amount of data..."

It is working very well and satisfied with the way the form pops up and allows me to edit the info and then gets passed back. The only thing I'm trying to figure out now is how to get the courser to go to either the beginning or end of the memo field when the form pops up. Right now, it's got the whole field highlighted so all the test shows up in black. It's too easy for someone to hit a key and wipe out everything in the memo field.

Thanks for your help...
 
I was just telling you that you could use OpenArgs to pass the reference from the calling form. When you pass the reference via OpenArgs, you can then re-use the contents of OpenArgs to set the values back to the calling form.

Look into SelStart
 
I was just telling you that you could use OpenArgs to pass the reference from the calling form. When you pass the reference via OpenArgs, you can then re-use the contents of OpenArgs to set the values back to the calling form.

Look into SelStart

Thanks for hint. I'm trying to see if the users will like having the insertion point at the beginning or the end of the memo field. Right now I'm going with the end, but just a quick change and it could go to the beginning. If anyone is interested, it looks like this...

Private Sub Form_Load()
Me.TxtTextField.SetFocus
'Me.TxtTextField.SelStart = 0 'This in case they want it at the beginning
Me.TxtTextField.SelStart = Len(TxtTextField.Text) + 1 'This makes it go to the end
End Sub

Thanks again.
 
My guess is, since they are adding to it they would like it to go to the end. By the way, you should test that your memo field contains a value before using SelStart because it will error if it's empty.

Happy developing!
 
My guess is, since they are adding to it they would like it to go to the end. By the way, you should test that your memo field contains a value before using SelStart because it will error if it's empty.

Happy developing!

Yes I noticed that, so I added a check on the trigger in case the field is empty.

Me.Refresh
If Nz(Me.ActiveControl) = 0 Then
StrZoomText = ""
Else
StrZoomText = Me.ActiveControl
End If

But I think I'm going to go to the start of the field instead of the end because I've noticed that although it goes to the end, the screen itself also scrolls down so that you only see the last line at the top of the memo field. So the user will have to scroll up to see the whole memo. Not sure how to get the cursor to go to the end and still be able to see the whole memo.
 
I can't advise without knowing what your form looks like or seeing what exactly it does.
 

Users who are viewing this thread

Back
Top Bottom