If else decision making

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jay

    #1

    If else decision making

    Can any one help? I am trying to automate my DB with VBA and need help
    with the following. I have a subform that shows orders for
    advertisements placed. I would like to read the user input to test the
    value of two fields. The first has a cbo of ad sizes set as full, 1/2
    page etc..The second is a price field as currency
    I am trying to do the following:

    when cost has been input
    read cboAd size option and read txtCost.
    If cost is less than or equal to rate card cost for ad size chosen
    setfocus to next field
    else if price entered is higher than rate card
    display message box
    set txtcost at rate card price
    and setfocus at txtcost field.

    I'm having partial success but I can get the programme to recognize
    what ad size has been chosen so an error message is displayed
    regardless if the cost is over rate set. Can anyone tell me how to do
    this correctly? Thanks Jay

  • pietlinden@hotmail.com

    #2
    Re: If else decision making


    Jay wrote:
    Can any one help? I am trying to automate my DB with VBA and need help
    with the following. I have a subform that shows orders for
    advertisements placed. I would like to read the user input to test the
    value of two fields. The first has a cbo of ad sizes set as full, 1/2
    page etc..The second is a price field as currency
    I am trying to do the following:
    >
    when cost has been input
    read cboAd size option and read txtCost.
    If cost is less than or equal to rate card cost for ad size chosen
    setfocus to next field
    else if price entered is higher than rate card
    display message box
    set txtcost at rate card price
    and setfocus at txtcost field.
    >
    I'm having partial success but I can get the programme to recognize
    what ad size has been chosen so an error message is displayed
    regardless if the cost is over rate set. Can anyone tell me how to do
    this correctly? Thanks Jay
    What if you were to include the cost for the add size in the
    controlsource for the combobox cboAd? Then you could just point to
    it...

    if me.txtCost>me.c boAd.Columns("R ateCardCost") Then
    msgbox "Cost is wrong..."
    me.txtCost=me.c boAd.Columns("R ateCardCost")
    else
    me.ctlNextContr ol.Setfocus '---whatever the next control is...
    end if

    or something like that... Basically I'm cheating and hiding hte {size,
    cost} pairs in the combobox's controlsource so it's already in the
    form. then I don't have to do any PITA lookups.

    HTH,

    Pieter

    Comment

    Working...