hello please help me how to connect my program to microsoft acces...please help me because i don't have any idea on how to connect ...hoping for your positive responds...here's my code..
Private Sub cmdAdd_Click()
For i = 1 To Len(txtLname)
If IsNumeric(Mid(txtLname.Text, i, 1)) = True Or (Mid(txtLname.Text, i, 1)) = "." Then
MsgBox "NO Last name have numbers or special character", vbInformation, " Invalid Last name"
Call highlightAll(txtLname)
Exit Sub
End If
Next i
If Trim(txtLname.Text) < "A" Then
MsgBox "Invalid,Please input again", vbInformation, "Invalid Last name"
Call highlightAll(txtLname)
Exit Sub
End If
If Trim(txtFname.Text) < "A" Then
MsgBox "Invalid,Please input again", vbInformation, " Invalid First name"
Call highlightAll(txtFname)
Exit Sub
End If
If Len(Trim(txtmname.Text)) <> 1 Then
MsgBox "Input only your Middle initial", vbInformation, " Invalid Middle initial"
Call highlightAll(txtmname)
Exit Sub
End If
If Trim(txtmname.Text) < "A" Then
MsgBox "Invalid Middle initial Please input again", vbInformation, " Invalid Middle initial"
Call highlightAll(txtmname)
Exit Sub
End If
If Trim(txtAddres.Text) = "" Then
MsgBox "Invalid Address.. Please input your Address again", vbInformation, " Invalid Address"
Call highlightAll(txtAddres)
Exit Sub
End If
If (Val(txtAge.Text)) <= 0 Then
MsgBox "Invalid input on your age", vbCritical, "Only 18yrs. to 90yrs old"
Call highlightAll(txtAge)
Exit Sub
ElseIf (Val(txtAge.Text)) < 18 Or (Val(txtAge.Text)) > 90 Then
MsgBox "your not qualified voter", vbCritical, "OOOPs! sorry..."
txtLname.Text = ""
txtFname.Text = ""
txtmname.Text = " "
txtAddres = ""
txtAge = ""
Exit Sub
End If
pn = Trim(txtc.Text) & "-" & Trim(txtPn.Text)
adress = Trim(Me.lblAddress.Caption)
vidno = Trim(lblVidno.Caption)
last = Trim(txtLname.Text)
first = Trim(txtFname.Text)
middle = Trim(txtmname.Text)
address = Trim(Me.txtAddres)
age = Val(txtAge.Text)
grd.TextMatrix(grd.Rows - 1, 0) = vidno
grd.TextMatrix(grd.Rows - 1, 1) = pn
grd.TextMatrix(grd.Rows - 1, 2) = last
grd.TextMatrix(grd.Rows - 1, 3) = first
grd.TextMatrix(grd.Rows - 1, 4) = middle
grd.TextMatrix(grd.Rows - 1, 5) = address
grd.TextMatrix(grd.Rows - 1, 6) = age
grd.Rows = grd.Rows + 1
lblVidno.Caption = vidno + 1
lblVidno.Caption = Format(lblVidno, "0000")
generator
End Sub
Private Sub cmdcancel_Click()
txtLname.Text = ""
txtFname.Text = ""
txtmname.Text = " "
txtAddres = ""
txtAge = ""
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub header()
grd.Clear
grd.Rows = 2
grd.Cols = 7
grd.ColWidth(1) = 1500
grd.ColWidth(2) = 1500
grd.ColWidth(3) = 1500
grd.ColWidth(4) = 1500
grd.ColWidth(5) = 1500
With grd
.TextMatrix(0, 0) = "Voters I.D"
.TextMatrix(0, 1) = "Precint No"
.TextMatrix(0, 2) = "Last name"
.TextMatrix(0, 3) = "First name"
.TextMatrix(0, 4) = "Middle initial"
.TextMatrix(0, 5) = "Address"
.TextMatrix(0, 6) = "Age"
End With
End Sub
Public Sub generator()
n = Int(Rnd(1) * 10)
If n = 1 Or n = 2 Then
txtc.Text = "A"
txtPn.Text = "342"
lblAddress = "India"
Exit Sub
ElseIf n = 3 Or n = 4 Then
txtc.Text = "B"
txtPn.Text = "343"
lblAddress = "London"
Exit Sub
ElseIf n = 5 Or n = 6 Then
txtc.Text = "C"
txtPn.Text = "344"
lblAddress = "United states"
Exit Sub
ElseIf n = 7 Or n = 8 Then
txtc.Text = "D"
txtPn.Text = "345"
lblAddress = "Africa"
Exit Sub
Else
txtc.Text = "E"
txtPn.Text = "322"
lblAddress = "Singapore"
Exit Sub
End If
End Sub
Private Sub Form_Load()
header
generator
Me.Move (Screen.Width - Width) \ 3, (Screen.Height - Height) \ 2
End Sub