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

Jemz,

I suggest you do a little search on the web...
Here in DaniWeb are some tutorials that would help you, right?

If you don't know how to start, try googling "how to use ADO with VB6", and probably you'll get a lot of results. I use ADO for every connection I made - it's simply to use, relatively faster than DataControl and you need to know only two objects for programming: the Connection object and the Recordset object - I suggest that you search for a literature about these two components, it will very very helpfully in the future.


And, if you can't apply what you've searched or get any errors trying, please fell free to write again and put a less generical question...


You can start with these searches: VB6 ADO CONNECTION ACCESS (all of this words or any of them separated). I try all words same time in google and before ten results I found this http://support.microsoft.com/kb/168336 and this http://www.vb6.us/tutorials/database-access-ado-vb6-tutorial.


When you fell more confortable with these concepts and objects, try to search for "DNS less" connections too.


Good luck,
Sidnei

>>how to connect Microsoft access
I didn't read ur all code. on ur question I want to say. u can do it many way. one of the way is, simple put the data control in ur form. then in properties tab connect the database from database name. and then select the table from record source (in properties tab). u can follow what sidnei said. u can do it many way what depend on ur work.

Use ADO.

Please find the connection string here.

oki thanks for the reply...ahm but what about how to make the table im ms access can you give me some steps on this....thanks in advance hoping for your positive responds

I thinking if I understand your question...
Use the MS Access interface, create a new table with the fields you want...

If you don't have MS Access in your machine, you can try VisData, this program is probably installed on the same directory VB6 is in, commonly PROGRAM FILES\VISUAL STUDIO\VB98 - or some.


Is really this you asked for?

Sidnei

oki thanks for the reply...ahm but what about how to make the table im ms access can you give me some steps on this....thanks in advance hoping for your positive responds

ahm yup the visdata ahm how to make the table because i am confuse with the primary key what should i put there?help me please sindei

sindnei ahm just give me steps or tutorial on it how to make in visdata..thanks in advance hoping for your positive responds

ahm sidnei i've tried to code the connection at when i compile its ok no debug but when i input data i can't find in my ms access there are no data display only my header...please help me code this ....please see my program code above ..help me please...hoping for your positive responds

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.