|
Option Explicit
Sub gravar()
tblpes![codigo] = txtcodigo.Text
tblpes![nome] = txtnome.Text
tblpes![morada] = txtmorada.Text
tblpes![codpostal] = txtcodpostal.Text
tblpes![tel] = txttel.Text
tblpes![tm] = txttm.Text
tblpes.Update
End Sub
Sub mostrar()
txtcodigo.Text = tblpes![codigo]
txtnome.Text = tblpes![nome]
txtmorada.Text = tblpes![morada]
txtcodpostal.Text = tblpes![codpostal]
txttel.Text = tblpes![tel]
txttm.Text = tblpes![tm]
End Sub
Private Sub cmdactualizar_Click()
Call gravar
txtcodigo.SetFocus
End Sub
Private Sub cmdapagar_Click()
tblpes.Delete
txtcodigo.SetFocus
End Sub
Private Sub cmdgravar_Click()
tblpes.AddNew
Call gravar
txtcodigo.SetFocus
End Sub
Private Sub cmdnovo_Click()
txtcodigo.SetFocus
End Sub
Private Sub cmdsair_Click()
Unload Me
End Sub
Private Sub Form_KeyPress(KeyAscii As
Integer)
If KeyAscii = 13 Then
SendKeys "{TAB}"
KeyAscii = 0
End If
End Sub
Private Sub Form_Load()
Label1.Caption = etiqueta
End Sub
Private Sub txtcodigo_GotFocus()
txtcodigo.Text = ""
txtnome.Text = ""
txtmorada.Text = ""
txtcodpostal.Text = ""
txttel.Text = ""
txttm.Text = ""
cmdgravar.Enabled = False
cmdactualizar.Enabled = False
cmdapagar.Enabled = False
End Sub
Private Sub txtcodigo_KeyPress(KeyAscii
As Integer)
Select Case KeyAscii
Case vbKeyDelete
Case vbKeyBack
Case 48 To 57
Case Else
Beep
KeyAscii = 0
End Select
End Sub
Private Sub txtcodigo_LostFocus()
tblpes.Index = "chavecodigo"
tblpes.Seek "=", txtcodigo.Text
If Not tblpes.NoMatch Then
cmdactualizar.Enabled
= True
cmdapagar.Enabled
= True
tblpes.Edit
Call mostrar
Else
cmdgravar.Enabled
= True
txtnome.Text
= "."
txtmorada.Text
= "."
txtcodpostal.Text
= "."
txttel.Text
= "0"
txttm.Text
= "0"
End If
End Sub
Private Sub txtcodpostal_GotFocus()
txtcodpostal.SelStart = 0
txtcodpostal.SelLength = Len(txtcodpostal.Text)
End Sub
Private Sub txtcodpostal_KeyPress(KeyAscii
As Integer)
KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
End Sub
Private Sub txtmorada_GotFocus()
txtmorada.SelStart = 0
txtmorada.SelLength = Len(txtmorada.Text)
End Sub
Private Sub txtmorada_KeyPress(KeyAscii
As Integer)
KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
End Sub
Private Sub txtnome_GotFocus()
txtnome.SelStart = 0
txtnome.SelLength = Len(txtnome.Text)
End Sub
Private Sub txtnome_KeyPress(KeyAscii
As Integer)
KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
End Sub
Private Sub txttel_GotFocus()
txttel.SelStart = 0
txttel.SelLength = Len(txttel.Text)
End Sub
Private Sub txttel_KeyPress(KeyAscii
As Integer)
Select Case KeyAscii
Case vbKeyDelete
Case vbKeyBack
Case 48 To 57
Case Else
Beep
KeyAscii = 0
End Select
End Sub
Private Sub txttm_GotFocus()
txttm.SelStart = 0
txttm.SelLength = Len(txttm.Text)
End Sub
Private Sub txttm_KeyPress(KeyAscii As
Integer)
Select Case KeyAscii
Case vbKeyDelete
Case vbKeyBack
Case 48 To 57
Case Else
Beep
KeyAscii = 0
End Select
End Sub
|