11. Write a VB program to accept the details of customer having fields cno, cname, address,phone number. Display those details on to the screen using data report.(Don’t use standard controls).


Dim C As New Connection
Dim R As New Recordset
Dim S As String
Private Sub cmdAdd_Click()
txtCno.Text = “”
txtCName.Text = “”
txtCAddr.Text = “”
txtPhone.Text = “”

txtCno.SetFocus
End Sub
Private Sub cmdNext_Click()
R.MoveNext
If Not R.EOF Then

txtCno.Text = R.Fields(0).Value
txtCName.Text = R.Fields(1).Value
txtCAddr.Text = R.Fields(2).Value
txtPhone.Text = R.Fields(3).Value
Else
MsgBox “No More Records!”, vbInformation, “Customer”
End If
End Sub
Private Sub cmdPrev_Click()
R.MovePrevious
If Not R.BOF Then
txtCno.Text = R.Fields(0).Value
txtCName.Text = R.Fields(1).Value
txtCAddr.Text = R.Fields(2).Value
txtPhone.Text = R.Fields(3).Value
Else
MsgBox “No More Records!”, vbInformation, “Customer”
End If
End Sub
Private Sub cmdSave_Click()
R.Close
S = “Insert Into tblCust Values(” & Val(txtCno.Text) & “,'” & txtCName.Text & “‘,'” & txtCAddr.Text & “‘, ” & Val(txtPhone.Text) & “)”
R.Open S, C, adOpenDynamic, adLockOptimistic
S = “Select * From tblCust”
R.Open S, C, adOpenDynamic, adLockOptimistic
If Not R.BOF And Not R.EOF Then
R.MoveFirst
txtCno.Text = R.Fields(0).Value
txtCName.Text = R.Fields(1).Value
txtCAddr.Text = R.Fields(2).Value
txtPhone.Text = R.Fields(3).Value
End If
MsgBox “Employee Added Successfully!”, vbInformation, “Customer”

End Sub

Private Sub Command1_Click()
DataReport1.Show
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
S = “Select * From tblCust”
C.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\VBSlipSol\Slip11\Ques-2\cust.mdb;Persist Security Info=False”
R.Open S, C, adOpenDynamic, adLockOptimistic

If Not R.BOF And Not R.EOF Then
R.MoveFirst
txtCno.Text = R.Fields(0).Value
txtCName.Text = R.Fields(1).Value
txtCAddr.Text = R.Fields(2).Value
txtPhone.Text = R.Fields(3).Value
End If
End Sub

Private Sub frmeOne_DragDrop(Source As Control, X As Single, Y As Single)
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s