home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Unleashed
/
Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso
/
source
/
chap36
/
addcand.frm
(
.txt
)
< prev
next >
Wrap
Visual Basic Form
|
1995-08-03
|
6KB
|
227 lines
VERSION 4.00
Begin VB.Form frmAddCandidate
BorderStyle = 3 'Fixed Dialog
Caption = "Add Candidate"
ClientHeight = 1845
ClientLeft = 1440
ClientTop = 1665
ClientWidth = 6945
ControlBox = 0 'False
Height = 2250
Left = 1380
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1845
ScaleWidth = 6945
ShowInTaskbar = 0 'False
Top = 1320
Width = 7065
Begin VB.CommandButton cmdSaveStay
Caption = "Save && Sta&y"
Height = 465
Left = 5610
TabIndex = 5
Top = 30
Width = 1245
End
Begin VB.TextBox txtFirstName
Height = 285
Left = 120
MaxLength = 20
TabIndex = 1
Top = 900
Width = 2055
End
Begin VB.TextBox txtMiddleInitial
Height = 285
Left = 2310
MaxLength = 1
TabIndex = 2
Top = 900
Width = 375
End
Begin VB.TextBox txtLastName
Height = 285
Left = 2790
MaxLength = 25
TabIndex = 3
Top = 900
Width = 2055
End
Begin VB.TextBox txtPhone
Height = 285
Left = 120
MaxLength = 15
TabIndex = 4
Top = 1500
Width = 1215
End
Begin VB.TextBox txtTitle
Height = 285
Left = 120
MaxLength = 4
TabIndex = 0
Top = 300
Width = 615
End
Begin VB.CommandButton cmdCancel
Caption = "&Cancel"
Height = 465
Left = 5610
TabIndex = 7
Top = 1050
Width = 1245
End
Begin VB.CommandButton cmdSave
Caption = "&Save"
Height = 465
Left = 5610
TabIndex = 6
Top = 540
Width = 1245
End
Begin VB.Data dbaCandidate
Caption = "Candidate"
Connect = "Access"
DatabaseName = "c:\sams\maketeam"
Exclusive = 0 'False
Height = 300
Left = 5250
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "tblCandidate"
Top = 1560
Visible = 0 'False
Width = 1635
End
Begin VB.Label lblTitle
Caption = "Title"
Height = 255
Left = 120
TabIndex = 12
Top = 60
Width = 615
End
Begin VB.Label lblFirstName
Caption = "First Name"
Height = 255
Left = 150
TabIndex = 11
Top = 660
Width = 855
End
Begin VB.Label lblInitial
Caption = "Initial"
Height = 255
Left = 2280
TabIndex = 10
Top = 660
Width = 495
End
Begin VB.Label lblLastName
Caption = "Last Name"
Height = 255
Left = 2820
TabIndex = 9
Top = 660
Width = 855
End
Begin VB.Label lblPhone
Caption = "Phone"
Height = 255
Left = 150
TabIndex = 8
Top = 1260
Width = 615
End
Attribute VB_Name = "frmAddCandidate"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Sub PrepForm()
If gAction = 1 Then
'Add
frmAddCandidate.Caption = "Add New Candidate"
txtTitle = ""
txtFirstName = ""
txtLastName = ""
txtMiddleInitial = ""
txtPhone = ""
' picPicture = ""
Else
'Edit
Beep
MsgBox "Edit is an unsupported function here.", 16, gProgramTitle
Unload frmAddCandidate
End If
End Sub
Private Sub SaveInfo()
If gAction = 1 Then
dbaCandidate.Recordset.AddNew
Else
dbaCandidate.Recordset.Edit
End If
dbaCandidate.Recordset![Title] = txtTitle
dbaCandidate.Recordset![FirstName] = txtFirstName
dbaCandidate.Recordset![LastName] = txtLastName
dbaCandidate.Recordset![MiddleInitial] = txtMiddleInitial
' dbaCandidate.Recordset![picture] = picPicture
dbaCandidate.Recordset![Phone] = txtPhone
dbaCandidate.Recordset![Available] = True
dbaCandidate.Recordset![LastUpdate] = Now
dbaCandidate.UpdateRecord
End Sub
Private Function validInfo() As Boolean
validInfo = False 'Assume something is wrong.
If Len(Trim(txtTitle)) < 1 Then
MsgBox "You must enter a title. (e.g. Mr, Ms, Dr)", 64, gProgramTitle
txtTitle.SetFocus
Exit Function
Else
If Len(Trim(txtFirstName)) < 1 Then
MsgBox "You must enter a first name.", 64, gProgramTitle
txtFirstName.SetFocus
Exit Function
Else
If Len(Trim(txtLastName)) < 1 Then
MsgBox "You must enter a last name.", 64, gProgramTitle
txtLastName.SetFocus
Exit Function
End If
End If
End If
validInfo = True 'Must be okay.
End Function
Private Sub cmdCancel_Click()
gAction = -1
Unload frmAddCandidate
End Sub
Private Sub cmdSave_Click()
If validInfo() Then
SaveInfo
gAction = 0
frmMain.dbaCandidate.Refresh
Unload frmAddCandidate
End If
End Sub
Private Sub cmdSaveStay_Click()
If validInfo() Then
SaveInfo
'Do it again.
gAction = 1
PrepForm
txtTitle.SetFocus
End If
End Sub
Private Sub Form_Load()
Left = (Screen.Width - Width) / 2
TOP = (Screen.Height - Height) / 2
MousePointer = 0
dbaCandidate.DatabaseName = gMainDBName
dbaCandidate.Refresh
PrepForm
End Sub