Public Cn As New Connection
Public rs As New Recordset
Public Rstemp As New Recordset
Public CodBus As String
Public Sub Conectar()
Cn.Provider = "Microsoft.Jet.Oledb.4.0"
Cn.Open (App.Path + "\base\vac_jer.mdb")
End Sub
Public Sub llenarcombo(c As ComboBox, t As String, col As Integer)
If Rstemp.State = 1 Then Rstemp.Close
Dim Sql$
Sql = "select * from " + t
Rstemp.Open Sql, Cn, adOpenStatic, adLockOptimistic
Do While Not Rstemp.EOF
c.AddItem Rstemp(col)
Rstemp.MoveNext
Loop
Rstemp.Close
End Sub
Public Sub limpiar(f As Form)
Dim c As Control
For Each c In f
If (TypeOf c Is TextBox) Or (TypeOf c Is ComboBox) Then c.Text = ""
If TypeOf c Is OptionButton Then c.Value = False
Next
End Sub
Public Function BuscarDato(Tabla As String, Campo As String, Cond As String, Ncol As Integer) As String
Dim Sql$, Rstemp As New Recordset
Sql = "Select * From " + Tabla + " Where " + Campo + "='" & Cond & "'"
Set Rstemp = Cn.Execute(Sql)
If Not (Rstemp.EOF) Then
BuscarDato = Rstemp(Ncol)
Else
BuscarDato = ""
End If
Rstemp.Close
End Function
Public Sub main()
Call Conectar
INICIO.Show
End Sub
Public Function BuscarDatoNum(Tabla As String, Campo As String, Cond As String, Ncol As Integer) As String
Dim Sql$, Rstemp As New Recordset
Sql = "Select * From " + Tabla + " Where " + Campo + "= " & Cond & " "
Set Rstemp = Cn.Execute(Sql)
If Not (Rstemp.EOF) Then
BuscarDatoNum = Rstemp(Ncol)
Else
BuscarDatoNum = ""
End If
Rstemp.Close
End Function