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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do this "simple" procedure?

Status
Not open for further replies.

aim22

Programmer
Aug 17, 2007
7
0
0
MX
Im using macola vba ide to modify a form. I use the text box "ItemNo" when it loses focus i get 2 numbers from fields from the database (unit_price, uom_ratio) then i make a simple division to display a result on another Text Box created by me.

The problem is, that when there is more than one order for such item, then there is more than one unit_price. I need to navigate thru the ListBox but there aren't any helpful events... listbox only has GotFocus and LoseFocus. OrderNo has those 2 plus KeyDown, KeyUp and KeyPress.

I hope i made myself clear. An OnChange event would solve my problem in a second!!... any helpful ideas? Thank you.
 
What screen? Order Entry?

Please post the code for your lose
_focus event.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
The screen is order entry (OEITMHSQ)

Private Sub CustomerNo_LoseFocus(AllowLoseFocus As Boolean)
Dim ar As New ERSRecSet
Dim precio As Double
Dim radio As Double
ar.ConnectString = "DRIVER={SQL Server};" & _
"SERVER=" & macForm.ConnInfo.Server & ";UID=" & macForm.ConnInfo.User & ";PWD=" & macForm.ConnInfo.pwd & ";" & _
"DATABASE=" & macForm.ConnInfo.DB & ";"
ar.Open ("SELECT unit_price, uom_ratio FROM OELINHST_SQL WHERE item_no = '" & ItemNo.Text & "'")
precio = ar.Columns("unit_price").Value
radio = ar.Columns("uom_ratio").Value
Precioporunidadd.Text = precio / radio
End Sub
 
You said you need to navigate thru the listbox. Are you saying when you select one of the orders in the list box, you want to display the result of the division in your code?

If so I only see a few events on listbox navigation and I cannot get them to fire consistently. I will look at this some more but I am not sure this will work.



Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
exactly, whenever i select an order in the list box then the result of the division would be assigned to Precioporunidadd.Text

Thanks for looking into this. I too believe its hard with the (very) limited events.
 
The ListBox doesn't have a "Selected" event so the best I could come up with is the following:

Private Sub ListBox_Click()
Debug.Print macForm.OrderNo.Text
End Sub

As you select an item in the list box the OrderNumber will populate with the one that is selected. You could then calculate your formula using this event.

Hope it helps.
 
thank you spucelik.... I didnt know about the "click" event, as the ListBox component properties only shows me GotFocus and LoseFocus, where can i find out more about all the events that each component has?

Thanks for your help.
 
sorry i have to post again, the forum doesn't let me edit my last.
Concerning spucelik's solution, whenever i click an order in the ListBox, it already fills the OrderNo field. I was going to use the click event to extract the 2 fields i need, unit_price and uom_ratio.

But it doesn't seem to work. There aren't any compilation errors but does that Click event really exists?
 
I got the click event to work and display a message box with the order #. This means you should be able to do this.

However I don't believe you will be able to display the results of your division in a field, but you should be able to display it easily on a messagebox. You will need to change the WHERE clause of your code to look at ord_no = orderno.text and ord_type=type.text.

If you don't include order type, you may still be in a one-to-many relationship.

Also to consider is if the same item is on the order multiple times, with say different due dates, you will still have a one-to-many relationship. This I do not believe you will be able to overcome because line_no is not a part of the listbox data.

The best way to do this is probably to have NO flex code behind OEITMHSQ and make the user dbl click on the order # to drill down to the line item screen. Then write similar code behind this screen (OE0401). Then the issue should go away as the line # is available.

Besides, how should the user reasonably expect to get line item detail info without actually drilling to the line item in question?

Let me know if any of this is not clear.


Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
Well.. that's exactly it, the users here are UNreasonable with us programmers :p

But everything was clear, thank you very much for your help.
 
Glad to hear you have another alternative. You could also use the click event to make the databse call to get the 2 values you want and then poplulate the text box (macForm.TextBox.text) control the same as you would dislay the message box.

To get the list of events, within the VBA window select the control on the top left drop down and then the events will list on the right drop down.

Hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top