Solved

How to have macro copy a value but not the value when the macro is recorded

Posted on 2008-10-01
6
363 Views
Last Modified: 2013-11-25
I recorded a macro which goes from the sales transaction entry window to the Items (lookup) window.  It then goes back to the sales transaction entry window, pulls up the sales customer detail entry window, clicks on the customer button, copies the customer id, hits "ok" to close the window, hits "ok" to close the sales customer detail entry window, runs a search on the customer id to return items available to that customer.

The purpose of the macro is so our sales entry team only can select items that should be available for the current customer.  The problem is the macro is using the value from when the macro was recorded (ADF-CARROLT-CAR) and not the customer id value for the current record.  Any suggestions?
# DEXVERSION=10.0.313.0 2 2

CheckActiveWin dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 

  MoveTo field 'Lookup Button 7' 

  ClickHit field 'Lookup Button 7' 

NewActiveWin dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 

ActivateWindow dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 

ActivateWindow dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 

ActivateWindow dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 

ActivateWindow dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 

  MoveTo field 'Expansion Button 4' 

  ClickHit field 'Expansion Button 4' 

NewActiveWin dictionary 'default'  form 'SOP_Customer_Detail_Entry' window 'SOP_Customer_Detail_Entry' 

  MoveTo field 'Customer Button' 

  ClickHit field 'Customer Button' 

NewActiveWin dictionary 'default'  form 'RM_Customer_Inquiry' window 'RM_Customer_Inquiry' 

  CommandExec form BuiLtin command cmdEditCopy 

  MoveTo field 'OK Button' 

  ClickHit field 'OK Button' 

NewActiveWin dictionary 'default'  form 'SOP_Customer_Detail_Entry' window 'SOP_Customer_Detail_Entry' 

  MoveTo field 'OK Button' 

  ClickHit field 'OK Button' 

ActivateWindow dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 

ActivateWindow dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 

ActivateWindow dictionary 'default'  form 'SOP_Entry' window 'SOP_Entry' 

ActivateWindow dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup' 

  MoveTo field 'ASI_LU_View_Button' item 1  # 'All Item Numbers' 

  ClickHit field 'ASI_LU_View_Button' item 2  # 'Customer Items' 

  MoveTo field 'PB_Advanced_Search' 

  ClickHit field 'PB_Advanced_Search' 

NewActiveWin dictionary 'SmartList'  form 'ASI_Advanced_Search' window 'ASI_Explorer_Criteria' 

  MoveTo field 'ASI_Search_Lookup_Button'[1] 

  ClickHit field 'ASI_Search_Lookup_Button'[1] 

NewActiveWin dictionary 'SmartList'  form 'ASI_Explorer_Fields' window 'ASI_Explorer_Fields' 

  MoveTo field '(L) LV_Fields' item 0  # ''

  ClickHitMS field '(L) LV_Fields' item 4  # 'Customer Number'

  SelChanged field '(L) LV_Fields' 

  DblClickHit field '(L) LV_Fields' item 4  # 'Customer Number'

NewActiveWin dictionary 'SmartList'  form 'ASI_Advanced_Search' window 'ASI_Explorer_Criteria' 

  MoveTo field 'ASI_Start_String'[1] 

  CommandExec form BuiLtin command cmdEditPaste 

  TypeTo field 'ASI_Start_String'[1] , 'ADF-CARROLT-CAR'

  MoveTo field 'OK Button K' 

  ClickHit field 'OK Button K' 

NewActiveWin dictionary 'SmartList'  form 'IV_Item_Number_Lookup' window 'IV_Item_Number_Lookup'

Open in new window

0
Comment
Question by:bradlee27514
6 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22686192
bradlee27514,

Obviously, the reference to ADF-CARROLT-CAR (Near the bottom of your snippet), needs to be "Relative"

Meaning it should be something like "CurrentRecord" or "CurrentCustomer"
something like this:
    TypeTo field 'ASI_Start_String'[1] , CurrentCustomer
How that is done in Dynamics, I am not sure.

The other option would be to store the Current Customer record as a variable, and use that.

For example:
Dim strCurrentCustomer as string
CurrentCustomer=Me.CurrentCustomer

Then in your code the line would be:

    TypeTo field 'ASI_Start_String'[1] , strCurrentCustomer

Now all of this is in "Global" terms, and is meant to give you an Idea of what needs to happen.

You can wait for another Expert (More experienced in MSDynamics Macro Recording) to chime in.

But my company uses Dynamics as well, and we have found that the technical support is superb.
Did you try giving them a call?

JeffCoachman
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 23208857
PAQed with no points refunded (of 500)

Computer101
EE Admin
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

Let’s list some of the technologies that enable smooth teleworking. 
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
This video will demonstrate how to find the puppet warp tool from the edit menu and where to put the points to edit.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

706 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

18 Experts available now in Live!

Get 1:1 Help Now