?
Solved

How set value of textbox on form with a macro?

Posted on 2014-01-03
7
Medium Priority
?
10,082 Views
Last Modified: 2014-01-12
I have a temp value "TempLocID" and would like to set the value of a text box [LocID] in a form that is already open and on the correct record.  I need to set this value with a macro.  How do I do this?  Assume that the macro is already running, has just set the temp value, and put the focus onto the previously mentioned form and record.
0
Comment
Question by:BD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 39754958
Have your tried this somewhere in the macro:

[LocId].Value = TempLocID

Open in new window


?

With ".Value" you don't need to set the focus.
0
 

Author Comment

by:BD
ID: 39755124
No clue where to put that.  What macro action should I be using?
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 39755519
It depends on when you want this to happen.  Basically you need to identify a" trigger" for this action, such as "when someone changes text in a text box (TextChanged event) or when the form is about to be saved (BeforeSave event) or when the use leaves a field (Leave event) or maybe when the record is first loaded (Current event).

e.g. on the Form object, in the properties' Events tab, double-click "On Current" and then click the [...] button to get to the code window and enter the above code.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:BD
ID: 39756148
The trigger will already have occurred.  Review the last sentence in my original post: "Assume that the macro is already running, has just set the temp value, and put the focus onto the previously mentioned form and record".  

So I have a good handle on how to trigger the event as the macro will already be running.  Where I am lost is understanding what additional actions I need to add to the currently running macro in order to set the value of the [LocID] text box with my temp value.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 39756428
Ah, I see the problem.  You create a "new macro".  Perviously Microsoft called VBA code macros.  With VBA macros, the above code works perfectly by simply inserting it into any appropriate sub.

If you don't want to migrate everything to VBA, then add the following:

Action = "SetProperty"
Control Name = LocID
Value = TempLocID

I haven't worked much with these macros in a long time, so see if the above works.  If not, attach the spreadsheet (minus any proprietary data) and I'll see what I can do.
0
 

Accepted Solution

by:
BD earned 0 total points
ID: 39762394
I have discovered the very macro action that accomplishes what I need to do!

It would appear, when using macros, that there is indeed a "SetValue" action, but MS Access hides it by default not allowing users to utilize this "Unsafe Action".  On the Design tab under the Show/Hide section there is a "Show All Actions" toggle button.  When active, users can see a whole new world of macro actions available to them.

Stupid, just stupid...

Thanks rspahitz for your assistance.
0
 

Author Closing Comment

by:BD
ID: 39774452
No other comment answered my original question, though rspahitz was helpful and eager.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question