Command button with calculation

G

Guest

I have a form with a command button that On_Click I would like to run a
calculation based on selections from other text boxes. I have written an
If..Then statement that runs correctly on another (unbound) text box, but
when placed in the On_Click code returns nothing. I know I am missing
something with the command button and would appreciate any help.
(The If..Then statement is the following:
If MedicationName = "Procrit" then
NewDose = txtWeight * 0.45
ElseIf MedicationName = "Aranesp" then
NewDose = txtWeight * 150
End If)

Thank you!
 
S

Steve

One of three things seems to be happening --
1. Code is not running whem you press the button
2. MedicationName is neither Procrit or Aranesp
3. txtWeight is Null

Temporarily change your code to the following to check for the above:
MsgBox "Code Runs!)
Msgbox "Medication Name is " & Me!MedicationName
MsgBox "txtWeight is " & Me!txtWeight
If MedicationName = "Procrit" then
NewDose = txtWeight * 0.45
ElseIf MedicationName = "Aranesp" then
NewDose = txtWeight * 150
End If

Let us know what messages you get.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
G

Guest

Thank you Steve...the combo box with Medication names was not being read
correctly...so I was able to fix that and now it is working perfectly. Many
thanks again.
Kbelo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top