Generic form data entry

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I want to be able to open a form for a single field data entry, pass it an
initial value for the field and when user closes the form to read the last
value of field on form back to the calling routine. Basically I need it to
be generic so it could be called form anywhere in the app for this single
field editing. How do I achieve this?

Thanks

Regards
 
One solution would be to declare a public variable of type Text box in a
standard module (so it is available application-wide.)
Public gtxtEditTarget As Textbox

Set this variable to the target control before you open the edit form, e.g.:
Set gtxtEditTarget = Me.[YourTextboxNameHere]
DoCmd.OpenForm "Form2", WindowMode:=acDialog

You can now read the value of the text box into your form, and assign the
result back later.

There's an example of this approach (used for date fields) here:
Popup calendar - an Access form that works as a calendar
at:
http://allenbrowne.com/ser-51.html

I assume you are doing more than what the Zoom box can do by pressing
Shift+F2.
 
You don't mention if this "prompt" form is going to be bound to a table or
not.

I explain the technique on how to open form, have user enter a value..and
then have the calling code examine the value(s) entered by the user.

http://www.members.shaw.ca/AlbertKallal/Dialog/Index.html


You simply would have to add to the above process code to "set" the value of
the text box by using the openargs paramater of the openFormCommand

Then:

in the forms on-load command you go:

me.NameOfTextBox = me.OpenArgs
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top