If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Run Time Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-23-11, 11:15
dongodu dongodu is offline
Registered User
 
Join Date: Sep 2010
Posts: 3
Run Time Error

Please see attached 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 Thumbnails
Run Time Error-new-picture-18-.jpg  
Reply With Quote
  #2 (permalink)  
Old 07-22-11, 09:55
Shayan Shayan is offline
Registered User
 
Join Date: Jul 2011
Location: Bandar Abbas - Iran
Posts: 9
This error occures when your Field type in Database and your value you passing to from your form doesn't match , check them or send your Database to check

Shayan.Firoozi@gmail.com

Try This may work :

For Numeric type we should not use '

Call recordset(rsemployee, cnemployee, "SELECT * FROM lands WHERE lnum=" & Combo2.Text & ")
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On