By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,472 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

If else decision making

P: n/a
Jay
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

Jul 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

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.cboAd.Columns("RateCardCost") Then
msgbox "Cost is wrong..."
me.txtCost=me.cboAd.Columns("RateCardCost")
else
me.ctlNextControl.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

Jul 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.