All pastes #1904490 Raw Edit

Moniga2010

public text v1 · immutable
#1904490 ·published 2010-07-20 14:19 UTC
rendered paste body

Public conn As Adodb.Connection
Public Sub newConnection()
Set conn = New Adodb.Connection
    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\base\books.mdb;Persist Security Info=False"
    If conn.State <> 1 Then
        conn.CursorLocation = adUseClient
        conn.Open
        Exit Sub
    End If
    End Sub

Private Sub CmdNew_Click()
Dim vbvalue As String
Dim i As Integer
Dim flag As Integer

For i = 0 To Combo2.ListCount
    If Combo2.List(i) = Trim(Text1.Text) Then
       flag = 1
    End If
Next

If flag <> 0 Then
   MsgBox "Bookcode already exist", vbCritical
End If
End Sub

Private Sub Combo1_LostFocus()
Text1.Enabled = False
Combo2.Clear
Dim custname As String
custname = Combo1.Text
Dim Myrs As New Adodb.Recordset
    Dim MySql As String
      Call newConnection
  MySql = "select bookname from cust where customer = '" & custname & "'"
    Myrs.Open MySql, conn, adOpenDynamic, adLockOptimistic
    Do Until Myrs.EOF
        Combo2.AddItem Myrs("bookname")
        Myrs.MoveNext
    Loop
End Sub

Private Sub Command2_Click()
Dim Myrs As New Adodb.Recordset
    Dim MySql As String
    Dim bookcode, cust As String
    bookcode = Trim(Text1.Text)
    cust = Trim(Combo1.Text)
    Call newConnection
    MySql = "insert into cust values '" & bookcode & "' '" & cust & "'"
End Sub

Private Sub Form_Load()
    Combo1.Clear
    Dim Myrs As New Adodb.Recordset
    Dim MySql As String
    Call newConnection
    MySql = "select distinct customer from cust"
    Myrs.Open MySql, conn, adOpenDynamic, adLockOptimistic
    Do Until Myrs.EOF
        Combo1.AddItem Myrs("customer")
        Myrs.MoveNext
    Loop
End Sub

Private Sub OptEx_Click()
Text1.Enabled = False
Combo2.Clear
Dim custname As String
custname = Combo1.Text
Dim Myrs As New Adodb.Recordset
    Dim MySql As String
      Call newConnection
  MySql = "select bookname from cust where customer = '" & custname & "'"
    Myrs.Open MySql, conn, adOpenDynamic, adLockOptimistic
    Do Until Myrs.EOF
        Combo2.AddItem Myrs("bookname")
        Myrs.MoveNext
    Loop
End Sub

Private Sub OptNew_Click()
Text1.Enabled = True
End Sub