| | |
Data-Access with Vbasic
![]() |
•
•
Join Date: Jul 2007
Posts: 23
Reputation:
Solved Threads: 0
hi friends!
I'm new to both vb and dataAccess. Now i have created a form in data-access. I need the datas entered in the form to be appended in the access-Table when i click the save button.
For eg:
Roll NO : Txt box
Name : Txt box
Sex : Txt box
Class : Txt box
New_Button Save_button
Here whenever i cllick the new_button all tha above fields to be re-set except the roll No. It has to display the next Roll No.(For eg. The previous roll No saved is 02ME11, Now it has to display 02ME12).
Then when i click the save_button, the datas has to be saved in access table.
please send me the code for this
elanch
I'm new to both vb and dataAccess. Now i have created a form in data-access. I need the datas entered in the form to be appended in the access-Table when i click the save button.
For eg:
Roll NO : Txt box
Name : Txt box
Sex : Txt box
Class : Txt box
New_Button Save_button
Here whenever i cllick the new_button all tha above fields to be re-set except the roll No. It has to display the next Roll No.(For eg. The previous roll No saved is 02ME11, Now it has to display 02ME12).
Then when i click the save_button, the datas has to be saved in access table.
please send me the code for this
elanch
hi,
Use the below codings.
' To create an object for connection and recordset
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
'To Create a New Id
Private Sub cmbnew_Click()
rs.Open "SELECT Mid([rollno],5,6) + 1 FROM Table1", cn, adOpenDynamic, adLockOptimistic
Text1.Text = "02ME" + Trim(Str(rs(0)))
rs.Close
End Sub
'To Add records
Private Sub cmdadd_Click()
rs.Open "select * from table1", cn, adOpenDynamic, adLockOptimistic
rs.AddNew
rs(0) = Text1.Text
rs(1) = Text2.Text
rs(2) = Text3.Text
rs(3) = Text4.Text
rs.Update
rs.Close
End Sub
'To Set connections.
Private Sub Form_Load()
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "dani", False, False
End Sub
Regards
Shailu
Use the below codings.
' To create an object for connection and recordset
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
'To Create a New Id
Private Sub cmbnew_Click()
rs.Open "SELECT Mid([rollno],5,6) + 1 FROM Table1", cn, adOpenDynamic, adLockOptimistic
Text1.Text = "02ME" + Trim(Str(rs(0)))
rs.Close
End Sub
'To Add records
Private Sub cmdadd_Click()
rs.Open "select * from table1", cn, adOpenDynamic, adLockOptimistic
rs.AddNew
rs(0) = Text1.Text
rs(1) = Text2.Text
rs(2) = Text3.Text
rs(3) = Text4.Text
rs.Update
rs.Close
End Sub
'To Set connections.
Private Sub Form_Load()
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open "dani", False, False
End Sub
Regards
Shailu
hi,
use below code.
'Create an object for connection and recordset
'set reference
'Project -> Reference - > Microsoft Activex Data Objects 2.6 Library
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Form_Load()
'Set Connections and recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
'Create DSN by
'In Run Command type "odbcad32" and press enter
'Then in userDSN tab click ADD button, select "Microsoft Access Driver(*.mdb), type any name in Data Source Name, click the Database button,Select access Database where u stored.
use that DSN name in connection open. Here i used DSN name "dani"
cn.Open "dani", False, False
End Sub
regards.
shailu.
use below code.
'Create an object for connection and recordset
'set reference
'Project -> Reference - > Microsoft Activex Data Objects 2.6 Library
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Form_Load()
'Set Connections and recordset
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
'Create DSN by
'In Run Command type "odbcad32" and press enter
'Then in userDSN tab click ADD button, select "Microsoft Access Driver(*.mdb), type any name in Data Source Name, click the Database button,Select access Database where u stored.
use that DSN name in connection open. Here i used DSN name "dani"
cn.Open "dani", False, False
End Sub
regards.
shailu.
![]() |
Similar Threads
- Get data from Access instead of Notepad (URGENT) (C#)
- Problem with retrieving data from access 2003 (Visual Basic 4 / 5 / 6)
- How can i access data from MS Access using VB6 (I need the connection code) (Visual Basic 4 / 5 / 6)
- VB6 and MS Access Problem (Visual Basic 4 / 5 / 6)
- C++ and data access (C++)
- Inserting Data into Access Database (Java)
- Creating data access layer in java (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: var or string value goes into another form
- Next Thread: problem with report in notepad
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading refresh remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





