Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selection to turn data entered into a negative value

Status
Not open for further replies.

1starr

Programmer
Feb 19, 2002
34
US
I have a form that has a drop down box where the customer can select an item. I have three items which if select I want it to turn data enter into the text field into a negative value when the customer inputs their data, but only when they make that selection. I am stumped on how to get this accomplish. Do anyone have a hint or have encountered this situation, please help.
 
Assume that the items on the drop down box which controls whether the users input is negative or not are, “cat”,”dog”, and “bird”. Any other selection from the box has no effect on that value. Say also that your combo box is named DropDwnBox and the name of the numeric variable on your form is called quest.

Now, you want to make your test after the user has put something into quest, and you also have to take into effect the fact that the user may not change the value of quest but he may have changed the combo box from a neutral value to one of the three choices being discussed. Therefore, it is probably best to test at the point when the form is about to be updated rather than when the value of quest may or may not have changed. Put something along the lines of the following code in your forms before update event.

If me.quest.value > 0 then
Select case me.dropdwnbox.value
Case “dog”
Case “cat”
Case “bird”
Me.quest.value = me.quest.value * -1
Case else
End select
End if

The case you have not mentioned and the one I have not approached is if the combochoice is not a member of the unholy three but the value of quest is negative. Do you need to change that now to a positive? You should not have a difficult time handling that in the above model.
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
I tried the code you give me in the before and after update and needed one seems to make the number value that the user inputs into a negative number. Here is an example of the coding I used.
If Me.txtAmount.Value > 0 Then
Select Case Me.cboService_Code
Case "4010", "4020", "4030"
Me.txtAmount.Value = Me.txtAmount.Value * -1
Case Else

End Select
End If
If I just can get the code to turn the numberic value in the text field to negative I would be a happy camper. If you have anymore subjections I would greatly appreciated. Thank you.
 

Well, let’s see if we can make you a happy camper. It appears to me as if your txtAmount.value is numeric, not a string,so we are going to treat it like what is…numbers. Remember, even though it is being shown in a text box, a text box is quite happy with numeric values. The true value data type is how it is defined on the table, and I suspect it is a number. Therefore, the code should be as follows

If Me.txtAmount.Value > 0 Then
Select Case Me.cboService_Code
Case 4010, 4020, 4030
Me.txtAmount.Value = Me.txtAmount.Value * -1
Case Else

End Select
End If

Done deal.
Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Unforunately that still did not get the change the input into a negative number, but thanks for helping.
 
Unforunately that still did change the input into a negative number, but thanks for helping.
 
Set a break point on If Me.txtAmount.Value > 0 Then.

Call the immediate window (control G) and do a
?me.txtamount.value. This will show you the value as the program sees it and make sure it is not a text string and is either 4010,4020,4030. Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
Thanks,
I see what's going on now. Instead of reading the service_code it's reading the service_codeID. Thanks, it's working correctly now. I don't know why I didn't think about doing that at the being. You have been a great help. Again THANK YOU.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top