?
Solved

How set value of textbox on form with a macro?

Posted on 2014-01-03
7
Medium Priority
?
11,020 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
  • 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…
Suggested Courses

850 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