cancel
Showing results for 
Search instead for 
Did you mean: 

first,previous,next,last Recordset using VB .net

Former Member
0 Kudos

Hi guys,

I created a recordset,

                                    oRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

                                    oRecordSet.DoQuery("Select ""ItemCode"",""ItemName"" FROM OITM ORDER BY ""ItemName"" ")

then after that, I created a first,previous,next,last buttons,

                                   Select Case pVal.ItemUID

                                        Case "btnfirst" 'btnFirst

                                            oRecordSet.MoveFirst()

                                        Case "btnprev"

                                            If Not oRecordSet.BoF Then

                                                oRecordSet.MovePrevious()

                                            Else

                                                oRecordSet.MoveLast()

                                            End If

                                        Case "btnnext"

                                            oRecordSet.MoveNext()

                                            If oRecordSet.EoF Then

                                                oRecordSet.MoveFirst()

                                            End If

                                        Case "btnlast"

                                            oRecordSet.MoveLast()

                                        End Select

All my buttons works properly,

now.. I want to create a textbox... on which i can search the itemcode on recordset.. my question  is... how to set the recordset on that ItemCode so that if i click the Buttons, ill get the correct output,,

THANKS,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

     You may try, oTextBox.Value = oRecSet.Fields.Item("ItemCode").Value

Regards,

Bry

Blog: http://www.sap-tips-tricks.com/

Former Member
0 Kudos

Hi bryan,

thanks for the reply but that is not my concern..     let me give an example

i have a recordset of items,

item1

item2

item3

item4

item5

this is the data of my recordset.

now.. i click FIRST button, the OUTPUT is ITEM1.

then.. i click NEXT button, the OUTPUT is ITEM2.

then.. i click NEXT button, the OUTPUT is ITEM3.

then.. i click LAST button, the OUTPUT is ITEM5.

then.. i click PREVIOUS button, the OUTPUT is ITEM4.


so remember.. my last ouput is ITEM4..


i have a textbox for searching items... i search ITEM1 on my recorset. of course the OUTPUT is ITEM1.


NOW, when i click the NEXT BUTTON, my OUTPUT is ITEM5..... which is wrong...

the OUTPUT should be ITEM2...because i searched the ITEM1 right? si if i click the NEXT button.. the OUTPUT should be ITEM2, and if i click the PREVIOUS button, the OUTPUT should be ITEM5.


that is my problem when searching an item.


PLEASE HELP






former_member185682
Active Contributor
0 Kudos

Hi Weynard,

How you search in your recordset?

If possible, post code of your search.

Regards,

Diego

Former Member
0 Kudos

i only type on textbox and press enter..this is my code;

Case SAPbouiCOM.BoEventTypes.et_KEY_DOWN

                                        Select Case pVal.ItemUID

                                            Case "txtItmCode"

                                                If pVal.CharPressed = "13" Then

                                                    oForm.Freeze(True)

                                                   ItemCode = oForm.Items.Item("txtItmCode").Specific.value

                                               

                                        End Select

                            End Select

former_member185682
Active Contributor
0 Kudos

Weynard,

If I understood , is because you aren't navigate in your recordset until the register that you need.

You can try something like this(is not beautiful, but i think it's solve your problem):

Case SAPbouiCOM.BoEventTypes.et_KEY_DOWN

                                        Select Case pVal.ItemUID

                                            Case "txtItmCode"

                                                If pVal.CharPressed = "13" Then

                                                    oForm.Freeze(True)

                                                   ItemCode = oForm.Items.Item("txtItmCode").Specific.value

                                                   while(ItemCode != oRecordSet.Fields.Item("ItemCode").Value)

                                                      

                                                      oRecordSet.MoveNext()

                                                      If oRecordSet.EoF Then

                                                          oRecordSet.MoveFirst()

                                                      End If

                                                  End while

                                              

                                        End Select

                            End Select

Regards,

Diego

Former Member
0 Kudos

HI Diego,

I did the same logic.

                                   oRecordSet.MoveFirst()

                                    Do

                                        oRecordSet.MoveNext()

                                    Loop Until (oRecordSet.Fields.Item(0).Value = ItemCode)

but this is too slow to load the data... imagine that you have 300 thousands records.. if i choose the last record.. it will loop 300thousand times.. do you have any codes to avoid this loop?

former_member185682
Active Contributor
0 Kudos

Weynard,

Now, I don't have other idea how to achieve this more faster. Sorry.

Regards,

Diego

Former Member
0 Kudos

Ok Diego,

Thanks for your fast reply

Answers (0)