A Simple Add, Edit, Delete, and Search using VB and MSAccess

This is a sample program on how to Add, Edit, Delete, and Search entries in database using VB and MS Access. Hope my code help you.
NOTE: THIS PROGRAM USES OCX, YOU MUST INSTALL THE PROJECT COMPONENTS BEFORE RUNNING THE PROGRAM.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Comments
please help me......
please help me.... this our problem? i want to search the textbox to data base....... pls give me example code
Please help in Project.
plz help me for the code that can edit,save,search,and delete
using vb6 nd msaccess...plz poh
help me please..
can i have a code in delete in vb 6.0 using ms access with the components of microsoft ADO Data Control 6. 0 (oledb) and
Microsoft Datagrid 6.0 Oledb.
Please. i need it ! ! !
email me : she_pacay@yahoo.com
for the codes..Thank You ! !
hi this is the code... kimkitur@gmail.com
Load the Visual Basic environment from your computer by clicking "Start>Programs>Microsoft Visual Studio 6.0>Microsoft Visual Basic 6.0".
2
Select "Standard EXE" from the "New Project" dialog box that pops up. Click "Open" button to proceed.
3
Drag and drop controls from the "Toolbox" into the form to design the interface and set the individual properties afterward under the "Properties" window. A search form usually has text boxes where users type words to search against the database, labels, some command buttons, grid to display the result, and database control that links the form into the table within the database. Continue with designing the form as preferred.
4
Click "View>Code" from the menu to go to the code section. This is where you will write the source codes for your project.
5
Go to "Form_Load" event by clicking the appropriate event name from the drop-down boxes in the codes section. Input a code similar to the one below. This code will set the connection properties of your data control and connects the grid to the database file.
With Adodc1
.ConnectionString = "[Type your connection string here]"
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.CommandType = adCmdTable
.RecordSource = "[Type the name of a table or query here]"
.Refresh
End With
With Grid1
Set .DataSource = Adodc1
.HighLight = flexHighlightWithFocus
.ColWidth(0) = .ColWidth(0) + 1000 'this is sample column dimension; change as preferred
.ColWidth(1) = .ColWidth(1) + 1800
.ColWidth(2) = .ColWidth(2) + 1800
.ColWidth(3) = .ColWidth(3) + 2300
.Refresh
.TabIndex = 0
End With
6
Double-click the text box where the user will enter the search criteria. For example, the user wants to search certain last names from the database and he will type the letters into the search box. When matches are found, the records will be displayed on the grid. In the code section, go to "Text1_Change()" event and input a code similar to the following:
Dim t as String
If Text1.Text "" Then
If Adodc1.Recordset.RecordCount 0 Then
t = "*" + Text1.Text+ "*"
Adodc1.Recordset.Filter = "LastName like '" + t + "'"
End If
Else
Adodc1.Recordset.Filter = adFilterNone
End If
7
Press the "F5" key to run the project. Test the program and check if it's running as it should.
8
Save the project by clicking "File>Save Project As" from the menu and providing a descriptive filename.
hey guys help me out with printing
can you guys help me out with the codes in printing of records in ms access.....
Dim con As
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub cmdSave_Click()
If Text1 = "" Or Text2 = "" Or Text3 = "" Then
MsgBox "Please complete all fields!", vbCritical
Exit Sub
End If
cmd.CommandText = "insert into emp(Name,Gender,Age) values ('" & Text1 & "','" & Text2 & "', '" & Text3 & "')"
cmd.Execute
MsgBox "Record Successfully Saved!", vbInformation, "Confirmation"
If con.State = adStateOpen Then con.Close
con.Open "provider = microsoft.jet.oledb.4.0;data source = " & App.Path & "\emp.mdb"
rs.CursorLocation = adUseClient
rs.Open "select * from emp", con, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
rs.MoveLast
End Sub
----------------------------------------------------------------------------
Private Sub cmdSearch_Click()
Dim str1 As String
str1 = InputBox("Enter Stall Number :", "Search by Stall Number")
Adodc1.Recordset.Filter = "ID ='" & str1 & "'"
End Sub
-------------------------------------------------------------------------
Private Sub Form_Load()
Call opendb
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
If con.State = adStateOpen Then con.Close
con.Open "provider = microsoft.jet.oledb.4.0;data source = " & App.Path & "\emp.mdb"
rs.CursorLocation = adUseClient
rs.Open "select * from emp", con, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
-------------------------------------------------------------------------
Private Sub Form_Unload(cancel As Integer)
con.Close
End Sub
--------------------------------------------------------------------------
Private Sub txtSearch_KeyUp(KeyCode As Integer, Shift As Integer)
If con.State = adStateOpen Then con.Close
con.Open "provider = microsoft.jet.oledb.4.0;data source = " & App.Path & "\emp.mdb"
rs.CursorLocation = adUseClient
rs.Open "select * from emp", con, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
If Combo1.Text = "" Then
MsgBox ("Please select category to search!")
Combo1.SetFocus
End If
If txtSearch.Text = "" Then
MsgBox ("Please enter keyword to search!")
txtSearch.SetFocus
End If
If Combo1.Text = "" Or txtSearch.Text = "" Then
rs.Filter = ""
Exit Sub
End If
rs.Filter = Combo1.Text & " LIKE '" & txtSearch.Text & "*'"
End Sub
===============================================
Public con As New ADODB.Connection
Public rs As New ADODB.Recordset
Public cmd As New ADODB.Command
Public Sub opendb()
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=emp.mdb;Persist Security Info=False"
cmd.ActiveConnection = con
End Sub
Dim con As
hi do you have the sample for this? please send to my mail? thanks.. ktpagador@gmail.com
Hi po.
Can you help me naman po, sa codes for SEARCH? Salamat po. Eto po EMAIL KO latemplouevo@yahoo.com
How to update a column in Access database
Hi, guys. I am working on vb project, which will save client database.
I've done the coding of ADD, NEW, SAVE, EDIT button. Now, I am stuck at DELETE button. When I delete any particular client then I want my client_id (it's a column in my access database) should get updated (like if I have five clients in database and if I delete 3rd client, then the client_id should start from 1,2,3,4; not like 1,2,4,5)
I am using ADODB and Ms-access at backend, please help!!!!!
VB.NET
Hello,
Can you plz send me a program for inventory and maintenance management system inos VB.NET?
Thanking u lots
TQ very much Welch... Its
TQ very much Welch... Its really help me a lot.. \(^_^)/
:)
You are very much welcome :) I am glad I could help.
sales and inventory system
nid ur help doing our sales and inventory system using vb6...must connect it to a cloud system..help me plz..tnx!!here's my email:
sweetglez_14@yahoo.com
Programming
kuya panu po yung searching na lahat ng field sa database masesearch gamit isang textbox lang..
ayaw po kasi gumana ng gnwa ko .. 424 object required dw po..
eto po ohh, really need help.
Private Sub text1_Change()
On Error GoTo Err_text1_Change
Dim strSource As String
strSource = "select * from student where name like '" & Text1.Text & "%' || address like '" & Text1.Text & "%', db, 1, 3"
Set DataGrid.DataSource = rs
Exit_text1_Change: Exit Sub
Err_text1_Change: MsgBox Err.Number & " " & Err.Description
Resume Exit_text1_Change
End Sub
MARAMING SALAMAT PO!
Use "OR" and not "||"
Use "OR" and not "||"
strSource = "select * from student where name like '" & Text1.Text & "%' OR address like '" & Text1.Text & "%', db, 1, 3"
hai poh good day
can you help to create a program that when you add a details and shows in a program that has already added.... plzzzzz
?
Sorry if I don't get the question right. Do you want to create a program that checks if the detail you want to add is already added?
:D Thanks a lot
galing mong programmer.... ganun pala yun...
DarkEmo
x)
Thanks!
Thansk
thanks for sharing...
Life Challenges
x)
Welcome!
Please Help... :(
Hi,
is there someone who could help me as in basically.
codings for file maintenance (ADD,EDIT,DELETE,SAVE,SEARCH) using VB6 with Access and SQL format?
can i code each per command button?
Please check my below code;i have an error in {Run-time error '3265' item cannot be found in the collection corresponding to the requested name or ordinal
Option Explicit
Dim oCN As ADODB.Connection
Dim oRS As ADODB.Recordset
Dim cmd As ADODB.Command
Private Sub Command1_Click()
Dim catNewDB As ADOX.Catalog
Dim sDBPath As String
Dim sCreateDBString As String
Dim meSQL As String
Dim sConnectString As String
Dim mymsg As String
If Dir("C:\My Lesson", vbDirectory) "" Then
Else
Call MkDir("C:\My Lesson")
End If
sDBPath = "C:\My Lesson\mydb.MDB"
If Dir(sDBPath, vbNormal) "" Then
Kill sDBPath
End If
sCreateDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath & _
";Jet OLEDB:Engine Type=5;"
Set catNewDB = New ADOX.Catalog
catNewDB.Create sCreateDBString
Set catNewDB = Nothing
Set oCN = New ADODB.Connection
'Set oCN = Nothing
sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDBPath
'gani to structure
'#1 open connection
'#2 ur transaction/procedure
'#optional close ur connection
oCN.Open sConnectString
meSQL = "CREATE TABLE tbFile1 (FileID1 Long Identity(1,1)"
meSQL = meSQL & ",FIELD1 Text(25)"
meSQL = meSQL & ",FIELD2 Double"
meSQL = meSQL & ",FIELD3 Integer"
meSQL = meSQL & ",FIELD4 Memo"
meSQL = meSQL & ",FIELD5 Date"
meSQL = meSQL & ")"
oCN.Execute meSQL
meSQL = "INSERT INTO tbFile1(FIELD1,FIELD2,FIELD3,FIELD4,FIELD5)"
meSQL = meSQL & "VALUES ("
meSQL = meSQL & "'mae'"
meSQL = meSQL & "," & 1225.01
meSQL = meSQL & "," & 1225
meSQL = meSQL & "," & "'this is a sample of my first lesson creating database and connection'"
meSQL = meSQL & "," & "# 5 - 25 - 2010 #"
meSQL = meSQL & ")"
oCN.Execute meSQL
meSQL = "INSERT INTO tbFile1(FIELD1,FIELD2,FIELD3,FIELD4,FIELD5)"
meSQL = meSQL & "VALUES ("
meSQL = meSQL & "'ann'"
meSQL = meSQL & "," & 925.03
meSQL = meSQL & "," & 925
meSQL = meSQL & "," & "'this is my second lesson populating database database in table'"
meSQL = meSQL & "," & "# 9 - 25 - 2003 #"
meSQL = meSQL & ")"
oCN.Execute meSQL
Set oRS = New ADODB.Recordset
meSQL = "SELECT * FROM tbFile1"
oRS.Open meSQL, oCN, adOpenForwardOnly, adLockReadOnly, -1
If Not oRS.EOF Then
Do Until oRS.EOF
mymsg = "FIELD1=" & Trim(oRS.Fields("FIELD1").Value & "")
mymsg = mymsg & vbCrLf & "FIELD2 =" & Val(Trim(oRS.Fields("FIELD2").Value & ""))
mymsg = mymsg & vbCrLf & "FIELD3 = " & Val(Trim(oRS.Fields("FIELD3").Value & ""))
mymsg = mymsg & vbCrLf & "FIELD4 = " & Trim(oRS.Fields("FIELD4").Value & "")
mymsg = mymsg & vbCrLf & "FIELD5 =" & Val(Trim(oRS.Fields("# FIELD5 #").Value & ""))
'error in highlighted yello for field5 which happen to be for date format. please help
MsgBox mymsg
oRS.MoveNext
Loop
End If
oRS.Close
End Sub
Thank you.
Online Education
This is a nice tips and this is a very helpful. This script helpful for new user.
Online Education
hello sir i need edit button
hello sir i need edit button coding for VB.. plz send me coding. my email address is beeva09@gmail.com......Thnks
need help
paano ba magsave ng picture pag picture box ang ginamit??? ano'ng code and gagamitin????
THis simple program is very
THis simple program is very nice, I use it at work, at first I had problems with it because I did not know programming, but in the end it was ok.
add,delete,edit
anu po ung username at password?
vb or c# codes for add edit delete
can i see the codes for add edit delete using Datagrid?
thankyou
dikopoalam
ininstall ko. kala ko lalabas ung mga code, pano po gamitin...
add edit delete in vb
i'm aving trouble installing it. i can't open this file. what's my mistake? i did install it
Hello sir, Thanks for the
Hello sir, Thanks for the project
pls give me code for Data reports import to excel
and form data print in data reports
plsss
how can i process the flow of a grading system by using a visual basic
when you plsss help me im a bigenners of a system..tnx..
ganda
wow its beautyfull program..
project
hi
its musharraf shaikh here
please show the coding delete if in created form the rec will doesn't exist then we will how show message box of 'rec does not exist'
HELP!
Hello po. Pwede po ba ako humingi ng codes kung papano po iconnect yung biometrics sa Vb2008? Thank you.
code for visual basic
meron po bang may kung ano ang code kung pano mag send ng message sa cellphone gamit lang ang visual basic..
Pages
Add new comment