_Rest_ Posted May 15, 2006 at 06:07 PM Report #27584 Posted May 15, 2006 at 06:07 PM Boas! O meu problema e que quando o Case_number se repete dá erro pk não se pode duplicar valores na chave primaria. Eu queria meter uma msgbox a dizer k o valor esta repetido e ter a possibilidade para voltar a inserir... mas ja teitei e nao konsigo Dim CONDecsis As ADODB.Connection Dim rs As ADODB.Recordset Private Sub Form_Load() Set CONDecsis = New ADODB.Connection CONDecsis.ConnectionString = "Provider=Microsoft.jet.oledb.4.0; Data Source=" & App.Path & "\DB\Decsis.mdb" CONDecsis.Open CONDecsis.CursorLocation = adUseClient End Sub Private Sub Gravar() rs!case_number = txtcase_number.Text rs!num_chamada = txtnum_chamada.Text rs!tipo_produto = txttipo_produto.Text rs!modelo = txtmodelo.Text rs!num_cliente = txtcliente.Text rs!serial_number = txtserial_number.Text rs!observações = txtobservações.Text rs!avaria = txtavaria.Text rs!estado = txtestado.Text rs!localização = txtlocalização.Text End Sub Private Sub LimparText() txtcase_number.Text = "" txtnum_chamada.Text = "" txttipo_produto.Text = "" txtmodelo.Text = "" txtcliente.Text = "" txtserial_number.Text = "" txtobservações.Text = "" txtavaria.Text = "" txtestado.Text = "" txtlocalização.Text = "" End Sub Private Sub cmdAdicionar_Click() Set rs = New ADODB.Recordset rs.CursorType = adOpenStatic rs.CursorLocation = adUseClient rs.LockType = adLockPessimistic rs.Source = "Select * From Chamadas" rs.ActiveConnection = CONDecsis rs.Open rs.AddNew Call Gravar rs.Update Call LimparText End Sub
Tiago Salgado Posted May 16, 2006 at 09:39 AM Report #27666 Posted May 16, 2006 at 09:39 AM Fazes uma verificação antes de inserires. Tipo... fazes um SELECT case_number FROM tabela Where case_number = txtcase_number.text Depois analisas o .RecordCount ...se for igual a 0 entao executas o código para inserir...se for diferente de 0 entao envias a MsgBox e não executas o codigo para inserir ... Cumps
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now