Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connection between Table and forms! 1

Status
Not open for further replies.

Koaz

Programmer
Nov 26, 2002
15
SG
How could i do a connection between the form and table, using DSN-less?
I had try something like this:

Sub DB_Connect()
Dim DataConn
Set DataConn = server.CreateObject("ADODB.Connection")
Dim db
db = "C:\Documents and Settings\HoRiZoN\Desktop\Eleave_convert.mdb"
DataConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" & db
DataConn.Open
End Sub

But it dun seem to work! Also, i will like to do an inserting of a row to the table, wat wil the coding be like?
 
try this

Dim Conn2 As ADODB.Connection
Dim Rs1 As ADODB.Recordset

Dim SQLCode As String

Set Conn2 = New ADODB.Connection
Set Rs1 = New ADODB.Recordset

Conn2.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = \\Compaqserver\apps\STOCK CODE LOOKUP.mdb"

SQLCode = "SELECT * FROM [yourTable] WHERE xxxx ....;"
Rs1.Open SQLCode, Conn2, adOpenStatic, adLockOptimistic
DougP, MCP
 
BTW did you check the ADO box in VBA editor

Click "Tools" menu then "References" then look for Microsoft ADO 2.x ...
put a check in the box on the left and click OK DougP, MCP
 
Oh!! Yes, i manage to debug the error.. thank for ur advise...
 
Erm.. But how do i execute my sql statement, if i wanted to insert data to table, instead of selecting from the table?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top