Solved

How set value of textbox on form with a macro?

Posted on 2014-01-03
7
8,094 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:iamsickofthisidshtuff
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:rspahitz
Comment Utility
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:iamsickofthisidshtuff
Comment Utility
No clue where to put that.  What macro action should I be using?
0
 
LVL 22

Expert Comment

by:rspahitz
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:iamsickofthisidshtuff
Comment Utility
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
Comment Utility
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:
iamsickofthisidshtuff earned 0 total points
Comment Utility
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:iamsickofthisidshtuff
Comment Utility
No other comment answered my original question, though rspahitz was helpful and eager.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now