?
Solved

How set value of textbox on form with a macro?

Posted on 2014-01-03
7
Medium Priority
?
10,575 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 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