1 Replies - 19978 Views - Last Post: 27 December 2012 - 09:25 PM Rate Topic: -----

#1 K.S  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 26-December 12

problem the loadin data

Posted 26 December 2012 - 08:43 PM

do not load the data in form
I press the enter key and call the function but this function call and do not load data,after that stuck the program
I,m using access data base
hear is my code
Private Function loaddataM()
    Rs.Open "SELECT * FROM Member_Type WHERE MTypeCode=" & Val(txtmtypeId.Text) & "", conString, adOpenDynamic, adLockOptimistic
    If Rs.BOF Then
        txtmtypeId.Text = Val(Rs.Fields("MTypeCode"))
        txtMdiscription.Text = Trim(Rs.Fields("Discription"))
    End If
End Function

Private Sub txtmtypeId_KeyPress(KeyAscii As Integer)

    If KeyAscii = 13 Then
        Call loaddataM
    End If
End Sub

This post has been edited by macosxnerd101: 26 December 2012 - 08:44 PM
Reason for edit:: Please use code tags

Is This A Good Question/Topic? 0
  • +

Replies To: problem the loadin data

#2 BobRodes  Icon User is offline

  • Lovable Curmudgeon
  • member icon

Reputation: 600
  • View blog
  • Posts: 3,071
  • Joined: 19-May 09

Re: problem the loadin data

Posted 27 December 2012 - 09:25 PM

Well, yes you do load the data. RS.Open does that. Then you check for BOF, which is never true unless the Recordset is empty. (BOF and EOF are both true when a Recordset is empty. When you open a Recordset and there are records in it, you'll be on the first record and BOF and EOF will both be false.) Then you unload it again right away. RS.Close does that.

So, the problem is that you need to check for Not RS.BOF rather than RS.BOF. What you should really do is this: If Not (RS.BOF And RS.EOF) Then
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1