?
Solved

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

Posted on 2008-10-01
6
Medium Priority
?
380 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
[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
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

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.

Question has a verified solution.

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

There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

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