- Katılım
- 2 Mart 2005
- Mesajlar
- 2,960
- Excel Vers. ve Dili
-
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
Kod:
'yazar ripek
Private Sub ComboBox6_Change()
'ikamet etmekte olduğu mahalle veya köy
On Error Resume Next
Dim Baglanti As ADODB.Connection: Dim Kayit1 As ADODB.Recordset: Dim SQLStr As String
On Error Resume Next
'SQLStr = "SELECT DISTINCT il, ilce,mahkoy,plaka,postakod,telkod FROM [ilveilce$] WHERE il=" & _
"'" & ComboBox4.Value & "'" & "AND ilce=" & "'" & ComboBox5.Value & "'" & "AND mahkoy=" & "'" & ComboBox6.Value & "'"
basliklar = "il, ilce, mahkoy, plaka, postakod, telkod"
sayfaadi = "[ilveilce$]"
sorgu = "il = " & " '" & ComboBox1.Value & "'" & "AND ilce=" & "'" & ComboBox2.Value & "'" & "AND mahkoy=" & "'" & ComboBox3.Value & "'"
SQLStr = "SELECT DISTINCT " & basliklar & " FROM " & sayfaadi & " WHERE " & sorgu
'************************************************'kynMHBRM dosya varsa bağlan>
If Dir(kynMHBRM) = "" Then
MsgBox kynMHBRM & " " & Chr(10) & " Dosyası Bulunamadı.", vbInformation, "Bilgi"
Exit Sub
End If
Set Baglanti = CreateObject("ADODB.Connection")
With Baglanti
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Properties("Data Source").Value = kynMHBRM
.CursorLocation = adUseClient
.Mode = adModeReadWrite
.CommandTimeout = 60
'.Properties("User ID") = vbNullString
'.Properties("Password") = vbNullString
.Open
End With
Set Kayit1 = CreateObject("ADODB.Recordset")
With Kayit1
.ActiveConnection = Baglanti
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Source = SQLStr
.Open
End With '<bitti
'************************************************'bitti<
'************************************************'verileri çek
Kayit1.MoveFirst
Label6.Caption = Kayit1.Fields("plaka")
Label5.Caption = Kayit1.Fields("postakod")
Label8.Caption = Kayit1.Fields("telkod")
Label24.Caption = Kayit1.Fields("telkod")
'************************************************'bağlantıyı kes
If CBool(Kayit1.State And adStateOpen) = True Then Kayit1.Close: Set Kayit1 = Nothing
If CBool(Baglanti.State And adStateOpen) = True Then Baglanti.Close: Set Baglanti = Nothing 'bitti
End Sub
Anlaşılacağı üzere
Kod:
sorgu = "il = " & " '" & ComboBox1.Value & "'" & "AND ilce=" & "'" & ComboBox2.Value & "'" & "AND mahkoy=" & "'" & ComboBox3.Value & "'"
Kod:
Label6.Caption = Kayit1.Fields("plaka")
Label5.Caption = Kayit1.Fields("postakod")
Label8.Caption = Kayit1.Fields("telkod")
Label24.Caption = Kayit1.Fields("telkod")
616
617
618
şeklinde görebilirmiyim. ve nasıl
kaynaktaki yeni başlığımız yrlkod olsun
yeni comboboxumzda combobox7 olsun