Results 1 to 2 of 2
  1. #1
    mcktigger is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    19

    Change Text Box Data Source On Open Event

    Hi All

    I have a form with a large number of text fields which simply display a high and low price for a range of products. Each field as the following code:

    =DLookUp("PriceCorrect","tblpricelist","ProductID = 52")

    I now need to add discounts prices but only for certain customers so I need to switch the code of each field to something like

    =DLookUp("PriceDiscounted","tblpricelist","Product ID = 52")

    this would change if the customer is flagged as being allowed discount. I don't want to create a new form and re-code each of the fields I want the field source to change automatically when the form opens.

    Is it possible to change the field source programatically on the on open event.



    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Use an IIf expression in the ControlSource

    = IIf([FlagField]=True,DLookUp("PriceDiscounted","tblpricelist","Pr oductID = 52"),DLookUp("PriceCorrect","tblpricelist","Produc tID = 52"))

    or

    = DLookUp(IIf([FlagField]=True,"PriceDiscounted","PriceCorrect"),"tblpricel ist","ProductID = 52")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-24-2012, 06:50 AM
  2. Replies: 1
    Last Post: 11-15-2011, 07:26 AM
  3. Replies: 0
    Last Post: 10-06-2010, 11:56 AM
  4. Using an event to change color of text.
    By michaeljohnh in forum Programming
    Replies: 3
    Last Post: 08-30-2010, 12:30 PM
  5. Data migration open source tool
    By pgdabler in forum Import/Export Data
    Replies: 0
    Last Post: 10-07-2009, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums