Jump to content

Run Time Error

- - - - -

  • Please log in to reply
3 replies to this topic

#1
dongodu

dongodu

    Newbie

  • Members
  • Pip
  • 4 posts
Please check attach file
Code for that
***********
Option Explicit
Private Const CB_SHOWDROPDOWN           As Long = &H14F
Private Const CB_GETDROPPEDSTATE        As Long = &H157
Private Drop                    As Boolean
Private Const CB_FINDSTRING = &H14C
Private Const CB_SELECTSTRING = &H14D
Private Const CB_LIMITTEXT = &H141
Private Const CB_ERR = (-1)
Dim rd As ADODB.connection
Dim cs As ADODB.recordset

Private Sub lan()
Set rd = CreateObject("Adodb.connection")
rd.Provider = "Microsoft.jet.oledb.4.0"
rd.Open App.Path & "\medrar.mdb"
Set cs = New ADODB.recordset
cs.Open "Select lnum from lands", rd, adOpenKeyset, adLockOptimistic
While Not cs.EOF
    Combo2.AddItem cs.Fields("lnum")
    cs.MoveNext
Wend
cs.Close
Set cs = Nothing
Drop = True

End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
Dim t$, rez&, l&
Combo2.SelText = ""
t$ = Combo2.Text & Chr$(KeyAscii)
rez& = SendMessage(Combo2.hwnd, CB_FINDSTRING, -1, ByVal t$)
If rez& <> CB_ERR Then
    l& = Len(t$)
    Combo2.Text = Combo2.List(rez&)
   Combo2.ListIndex = rez&
    KeyAscii = 0
    Combo2.SelStart = l&
    Combo2.SelLength = Len(Combo2.Text) - l&
End If
Dropdow
End Sub
Private Sub Combo2_LostFocus()
Dim t$, rez&
t$ = Combo2.Text
rez& = SendMessage(Combo2.hwnd, CB_FINDSTRING, -1, ByVal t$)
End Sub
Private Sub Dropdow()
   If Drop Then
      If SendMessage(Combo2.hwnd, CB_GETDROPPEDSTATE, 0, ByVal 0&) = 0 Then
         Call SendMessage(Combo2.hwnd, CB_SHOWDROPDOWN, 1&, 0&)
      End If
   End If
End Sub
Private Sub Combo2_Click()
Dim cnemployee As New ADODB.connection
Dim rsemployee As New ADODB.recordset

Call connection(cnemployee, App.Path & "\medrar.mdb", "endromida")
Call recordset(rsemployee, cnemployee, "SELECT * FROM lands WHERE lnum ='" & Combo2.Text & "'")

If rsemployee.RecordCount = 0 Then
MsgBox "The record you requested could not be found.", vbExclamation, "Fortune Systems Solutions"
Exit Sub
End If


With rsemployee

txtBlock.Text = .Fields!Pblk
txtPrname.Text = .Fields!PName
txtPrcode.Text = .Fields!pnum
txtSQFL.Text = .Fields!sqf_land
txtcost.Text = .Fields!f_sa_pr

End With

Set cnemployee = Nothing
Set rsemployee = Nothing
End Sub
Private Sub Form_Load()
Call lan
End Sub
*************

Attached Files


Edited by WingedPanther, 23 April 2011 - 08:13 AM.
add code tags (the # button)


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Did you select debug to find out which line of code generated the error?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
dongodu

dongodu

    Newbie

  • Members
  • Pip
  • 4 posts
Call recordset(rsemployee, cnemployee, "SELECT * FROM lands WHERE lnum ='" & Combo2.Text & "'")
This line Error

#4
dongodu

dongodu

    Newbie

  • Members
  • Pip
  • 4 posts
Resolved Error, Thnx u r Early Reply Friend.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users