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

Strange Behavior in Text Box

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

I have a list of Codes in Item Master like;

micode &&field name
------

B1236
B1236A
B1263L
C1776
C1776A
..
..
..

When I enter B1236A, it disappear the last 'A' in the list and shows only "B1236".

Please let me know what is wrong in this?

Thanks

Code in Lostfocus event:

Code:
If Lastkey()=13 Or Lastkey() = 9
   micode = Upper(This.Value)
   lenic  = Len(Alltrim(micode))
   If lenic = 1
      micode = ''
   Endif
   If ! Empty(micode)
      Select tIcode
      Index On icode Tag icode
      Seek micode In tIcode
      If ! Found()
         emessagetitle = 'Sales Order Entry'
         emessagetext = 'Code does not exist! Would you like to search?'
         ndialogtype = 4 + 16 + 256

         *  4 = Yes and No buttons
         *  16 = Stop sign icon
         *  256 = Second button is default

         nanswer = Messagebox(emessagetext, ndialogtype, emessagetitle)

         Do Case
            Case nanswer = 6
               Do Form '\forms\FindItem'
               Select icfind
               This.Value = icode
               micode = icode
               Select tIcode
               Set Order To icode
               Seek micode In tIcode
               This.Parent.Parent.mfull_desc.Value     = full_desc
               This.Parent.Parent.mbarcode.Text1.Value = barcode
               This.Parent.Parent.mSize.Value          = itemsize
               This.Parent.Parent.mTotwt.Value         = Totwt
               This.Parent.Parent.mNetwt.Value         = Netwt
               This.Parent.Parent.mPacking.Value       = Packing
               This.Parent.Parent.label13.Caption      = Unit
               mpic = Alltrim(This.Value)+'.jpg'
               This.Parent.Parent.ItemImage.Picture = '\GRAPHICS\PRODUCTS\&mpic'
               If ! File("&mpic")
                  This.Parent.Parent.ItemImage.Picture = '\GRAPHICS\PRODUCTS\no_image.jpg'
               Endif
               Thisform.Refresh() && instead of setting all the Value properties let controlsources do that via refresh
               Return 0
            Case nanswer = 7
               Nodefault
               Return .F.
         Endcase
      Else
         mpic = Alltrim(This.Value)+'.jpg'
         This.Parent.Parent.ItemImage.Picture = '\GRAPHICS\PRODUCTS\&mpic'
         If ! File("&mpic")
            This.Parent.Parent.ItemImage.Picture = '\GRAPHICS\PRODUCTS\no_image.jpg'
         Endif
         This.Parent.Parent.mfull_desc.Value     = full_desc
         This.Parent.Parent.mbarcode.Text1.Value = barcode
         This.Parent.Parent.mSize.Value          = itemsize
         This.Parent.Parent.mTotwt.Value         = Totwt
         This.Parent.Parent.mNetwt.Value         = Netwt
         This.Parent.Parent.mPacking.Value       = Packing
         This.Parent.Parent.label13.Caption      = Unit
         Thisform.grdcode.Left = 1045
         Thisform.grdcode.Top  = -195
         Thisform.grdcode.Visible = .F.
         Select pcrate
         Locate For icode = micode
         This.Parent.Parent.txtLastpricej.Value  = ratemaj
         This.Parent.Parent.txtLastpricen.Value  = ratemin
         Select GenData
         Set Order To icode
         Seek micode In GenData
         If Found()
            This.Parent.Parent.mQntyMaj.Value = QntyMaj
            This.Parent.Parent.mQntyMin.Value = QntyMin
            This.Parent.Parent.mRatemaj.Value = ratemaj
            This.Parent.Parent.mRatemin.Value = ratemin
            This.Parent.Parent.mQntyMaj.SetFocus
         Endif
      Endif
   Else
      This.Parent.Parent.mbarcode.SetFocus
   Endif
   Return .T.
Endif
 
1. Don't index everytime before you seek. If it's a table index it once in its (and your) lifetime, if it's a cursor create the index once after creating the cursor only.
2. Your code asks for Lastkey()=13 Or Lastkey() = 9, that means it only reacts to ENTER or TAB
3. You seek/Locate in the icode column of a table or cursor but don't display it. You display other things. This code alone doesn't tell anybody, what you really show, if you for exmaple set
4. You might have something as simple as a limitation of the number of character you can enter, see your maxlength setting.

Bye, Olaf.
 
Thanks Mr.Olaf

1. Understood
2. Understood
3. Select pcrate
Locate For icode = micode
This.Parent.Parent.txtLastpricej.Value = ratemaj
This.Parent.Parent.txtLastpricen.Value = ratemin

4. Max Length is 10
 
Yes, you set two textbox values to some rates. You don't show the icode

Debug at that point, what you really seek and find:
Code:
micode = Upper(This.Value)
If micode = 'B1236A'
   set step on
Endif

Then see what happens.

Bye, Olaf.
 
As Olaf suggested, we don't see any control where you say that you're not able to see the full text. Are you talking about the list shown in the FindItem form? If that is the case, you have see inside that form. Also, I think, icFind is the cursor returned/generated by the FindItem form. So, just after that form is called, SET STEP ON to check its structure and see the field length for item code. Similary in the tIcode table. You may get a clue I believe

Rajesh
 
Hi Rajesh

Both the lenght of the field "icode" in forms are same i.e., c(10).

Thanks

Saif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top