Eu não posso por o identif na tela porque ele é autonumeração e gera os códigos sozinhos. e essa tabela não está relacionada.
As intruções sql que uso em asp eu uso em VB. Não é igual eu sei, mais a sintaxe é igual. E de asp eu entendo, porque já programo em asp há um bom tempo. E as intruções sql que uso em asp podem ser usadas no vb.
esse é todo o meuy código de 1ª tela e nele está incluso o código para incluir.
Dim DB As New adodb.Connection
Dim tb As Recordset
Public DBName As String
Sub Preencher_Grade()
Dim SQL$, RS As adodb.Recordset, X&
msfAgenda.Rows = 1
SQL = "Select * From TB_CadContato"
SQL = SQL & " Order By Nome_Agenda"
Set RS = DB.Execute(SQL)
If Not RS.EOF Then
msfAgenda.Rows = RS.RecordCount + 1
For X = 1 To msfAgenda.Rows - 1
msfAgenda.TextMatrix(X, 0) = "" & RS("Nome_Agenda")
msfAgenda.TextMatrix(X, 1) = "" & RS("Telefone_Agenda")
msfAgenda.TextMatrix(X, 2) = "" & RS("EMail_Agenda")
msfAgenda.TextMatrix(X, 3) = "" & RS("Icq_Agenda")
msfAgenda.TextMatrix(X, 4) = "" & RS("Msn_Agenda")
If RS("Tipo_Contato") = 0 Then
msfAgenda.TextMatrix(X, 5) = "Amigos"
ElseIf RS("Tipo_Contato") = 1 Then
msfAgenda.TextMatrix(X, 5) = "Familiares"
Else
msfAgenda.TextMatrix(X, 5) = "Profissional"
End If
RS.MoveNext
Next X
End If
RS.Close
End Sub
Sub LimparFormulario()
txtNome = Empty
txtTelefone = Empty
txtEmail = Empty
txtIcq = Empty
txtMsn = Empty
optTipo(0).Value = True
optTipo(1).Value = Empty
optTipo(2).Value = Empty
End Sub
Private Sub cmdAdicionar_Click()
Dim SQL$, X%
SQL = "Insert Into TB_CadContato (Nome_Agenda, Telefone_Agenda, EMail_Agenda, "
SQL = SQL & " Icq_Agenda, Msn_Agenda, Tipo_Contato) Values("
SQL = SQL & "'" & Trim(txtNome) & "',"
SQL = SQL & "'" & Trim(txtTelefone) & "',"
SQL = SQL & "'" & Trim(txtEmail) & "',"
SQL = SQL & "'" & Trim(txtIcq) & "',"
SQL = SQL & "'" & Trim(txtMsn) & "',"
For X = 0 To optTipo.UBound
If optTipo(X).Value = True Then
SQL = SQL & "'" & X & "')"
End If
Next X
DB.Execute SQL
Call Preencher_Grade
Call LimparFormulario
txtNome.SetFocus
End Sub
Private Sub cmdExcluir_Click()
Dim SQL
Dim Identif As String
Identif = 1
MsgBox Identif
SQL = "Delete From TB_CadContato Where Identif = " & Identif
DB.Execute SQL
Call LimparFormulario
txtNome.SetFocus
End Sub
Private Sub cmdSair_Click()
DB.Close
Unload Me
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Sub Form_Load()
Call LimparFormulario
DB.CursorLocation = adUseClient
DB.Open "DBQ=Agenda_Contato.mdb; UID=administrador; PWD=; DRIVER={Microsoft Access Driver (*.mdb)}"
msfAgenda.Rows = 1
msfAgenda.Cols = 6
msfAgenda.FixedCols = 0
msfAgenda.TextArray(0) = "Nome"
msfAgenda.TextArray(1) = "Fone"
msfAgenda.TextArray(2) = "E-Mail"
msfAgenda.TextArray(3) = "ICQ"
msfAgenda.TextArray(4) = "MSN"
msfAgenda.TextArray(5) = "Tipo"
msfAgenda.ColWidth(0) = 2000
msfAgenda.ColWidth(1) = 1000
msfAgenda.ColWidth(2) = 3100
msfAgenda.ColWidth(3) = 1000
msfAgenda.ColWidth(4) = 2700
msfAgenda.ColWidth(5) = 1200
Call Preencher_Grade
End Sub
Private Sub MnuLocalizarContato_Click()
frmBuscaContato.Show
End Sub