469,159 Members | 1,526 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,159 developers. It's quick & easy.

VB and MS Access

I have written the following code.however, it is showing me an error on conn.open Please help me out as to what changes to make in it

Expand|Select|Wrap|Line Numbers
  1. Dim conn As ADODB.Connection
  2. Dim rs As ADODB.Recordset
  4. Private Sub Form_Load()
  5. Set conn = New ADODB.Connection
  6. conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data souce='My Documents\cityfk2003.mdb;'"
  7. conn.Open
  8. Set rs = New ADODB.Recordset
  9. rs.Open "select City from table1", conn
  10. Do While Not rs.EOF
  11. citycombo.AddItem rs("City")
  12. rs.MoveNext
  13. Loop
  14. End Sub
Sep 30 '11 #1
3 1208
12,516 Expert Mod 8TB
You need to use the full path.
Sep 30 '11 #2
32,167 Expert Mod 16PB
"My Documents" is a pseudo-address. It cannot be used in all places where an address is required. It's also not a very well considered location for storing a database.

You should consider moving the database to somewhere more appropriate or, alternatively, find where the actual address of "My Documents" and use that instead.
Sep 30 '11 #3
393 256MB
also 'data source' is misspelled in the string
Oct 4 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

63 posts views Thread by Jerome | last post: by
13 posts views Thread by Simon Bailey | last post: by
64 posts views Thread by John | last post: by
17 posts views Thread by Mell via AccessMonster.com | last post: by
37 posts views Thread by jasmith | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.