Results 1 to 5 of 5

Thread: [RESOLVED] Record doesnt show what it should be

Threaded View

  1. #1

    Thread Starter
    Fanatic Member ksuwanto8ksd's Avatar
    Join Date
    Apr 2005
    Posts
    636

    Resolved [RESOLVED] Record doesnt show what it should be

    Hi all

    My table (Access2k) contain records as this:

    TABLE Product:
    234
    A11
    ASW
    ASWW
    AWS

    TABLE Stock:
    234
    A11
    ASW
    ASWW

    In a form code I make like this:
    VB Code:
    1. Private Sub txtProductID_LostFocus()
    2. Dim msql As String
    3.  
    4. If txtProductID.Text <> "" Then
    5. con_Data.BeginTrans
    6.    
    7.   'Find product id from stock table
    8.   msql = "select * from stock " & _
    9.           " where productid='" & txtProductID.Text & "'"
    10.   Set Rs = con_Data.Execute(msql)
    11.                
    12.   'if product id found
    13.   If Not Rs.EOF Then
    14.          
    15.      'Display all fields
    16.      txtProductName.Text = Rs.Fields("productname")
    17.      txtUnit.Text = Rs.Fields("unit")
    18.      mseOpeningStock.Text = Rs.Fields("openingstock")
    19.      mseQuantity.Text = Rs.Fields("quantity")
    20.  
    21.      txtProductID.Enabled = False
    22.      txtProductName.Enabled = False
    23.      txtUnit.Enabled = False
    24.      mseQuantity.Enabled = False
    25.      mseOpeningStock.Enabled = False
    26.      cmdAdd.Enabled = True
    27.      cmdDelete.Enabled = True
    28.      cmdEdit.Enabled = True
    29.   Else
    30.    
    31.      'find product id from product table
    32.      msql = "select * from product " & _
    33.             " where productid='" & txtProductID.Text & "'"
    34.        
    35.      Set Rs1 = con_Data.Execute(msql)
    36.      
    37.      'if product id found
    38.      If Not Rs1.EOF Then
    39.            
    40.        'Display fileds
    41.        txtProductName.Text = Rs1.Fields("productname")
    42.        txtUnit.Text = Rs1.Fields("unit")
    43.            
    44.        txtProductID.Enabled = False
    45.        txtProductName.Enabled = False
    46.        txtUnit.Enabled = False
    47.        mseOpeningStock.Enabled = True
    48.        
    49.        cmdCancel.Enabled = True
    50.        mseOpeningStock.SetFocus
    51.      End If
    52.    Rs1.Close
    53.    End If
    54. Rs.Close
    55. con_Data.CommitTrans
    56. End If
    57. End Sub
    my problem is:

    When I type "AWS" in txtProductID it show "ASWW" and populate this record in textbox, and when I type "ASWW" or "ASW" or "234" or "A11" in txtProductID it work fine

    I really appreciate if anyone can advice on my coding above.
    thanks and "HAPPY NEW YEAR TO ALL"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width