1,105,375 Community Members

Adding to a Ms Access database using textbox

ohyeah
Light Poster
48 posts since Aug 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

Hi all,

Please somebody tell me the code.

I have :
a textbox name txtfname
a table named Customer (located in Database.mdb)

the customer table has only 1 field fname.

How do i create a connection such that whenever i click on add button, whatever is in the txtfname textbox is added to the table Customer.

I want to do it without Adodc. I want it to be with connection objects.

It starts like :

Private Sub cmdAdd_click()
Dim rs as new adodb.recordset
Dim conn as new adodb.connection
Dim str as String

conn.open “Provider=Microsoft.Jet.OLEDB.4.0; Data Source=”& App.Path & "\database.mdb"
rs.open
rs.addnew

rs!fname=txtfname.text

rs.close
conn.close

End Sub

Member Avatar
Eddy Jawed
Newbie Poster
6 posts since Apr 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Private Sub cmdAdd_click()
Dim str As String
Dim rs As New adodb.Recordset

str = txtfname.Value
rs.Open "SELECT * FROM [Customer]", CurrentProject.Connection, adOpenStatic, adLockOptimistic '

With rs
.addnew
.Fields("FieldName") = str
.Update
.Close
End With

End Sub

Member Avatar
Eddy Jawed
Newbie Poster
6 posts since Apr 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Where the field name is the name of one of the columns in your table that you want to add the text in your textbox to.

ohyeah
Light Poster
48 posts since Aug 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

Thanks bro

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article