Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old August 8th, 2003, 04:09 PM
marcel_911's Avatar
marcel_911 marcel_911 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Midlands, UK
Posts: 37 marcel_911 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 23 sec
Reputation Power: 6
Send a message via Yahoo to marcel_911
VBA Access. How do I open a database?

I know this is a stupid question, but the help in Access seems less that helpful. I seem to be following link after link and going round in ever decreasing circles. I'm afraid any second I'm going to disappear up my own .......

It would have been nice if the HELP in Access had an index or contents rather that just a search. How do I know what to search for? I don't know the terminology


I can't find any examples that work to help me.

I have the simplest of databases.....

It contains just ONE table, 20 columns and 7000 rows.

The data is already in the order I want it.

I want to be able to run through the data a row at a time and then output it to a html file (nicely formatted in a table), but split it and start another html file when certain fields change.

I am getting stuck just accessing the data.

Can someone please explain how I can open the table and read a field into a variable, and ideally how to step to the next record. Once I know that, I can manage the rest. (honestly )

If you do me a little example could you use the names below, so that I don't get too confused. Thanks.

Database is called "parts"
Table is called "unpriced"
Two columns called "partno" and "description"

Reply With Quote
  #2  
Old August 8th, 2003, 05:06 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,717 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 40 m 34 sec
Reputation Power: 688
From within Access 2000: click Help, Microsoft Access Help, and then click the contents tab to see the help table of contents.

You can simply open the table from the database window, then choose File - Export and select HTML as the export type. There is the opportunity to apply a HTML template.

You can use an Access query to use only part of the table or some of the columns. With a query results pane open you can use the File - Export menu to send it to HTML.

Reply With Quote
  #3  
Old August 8th, 2003, 05:56 PM
marcel_911's Avatar
marcel_911 marcel_911 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Midlands, UK
Posts: 37 marcel_911 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 23 sec
Reputation Power: 6
Send a message via Yahoo to marcel_911
Thanks. I had that stupid office assistant keep coming up. I got shot of him now I can see a contents page.

I'm not sure exporting as HTML will be any use to me. I needed to create a "title" page with some drop down boxes that directed the viewer to one of several hundred HTML pages. I wanted to do that automatically.

Anyway now I can see the help properly I might be able to find what I want.

Thanks again.

Reply With Quote
  #4  
Old August 10th, 2003, 02:57 PM
marcel_911's Avatar
marcel_911 marcel_911 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Midlands, UK
Posts: 37 marcel_911 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 23 sec
Reputation Power: 6
Send a message via Yahoo to marcel_911
I found an ADO tutorial on another forum and it seems to tell me everything I need to know for my project.

I am getting an error though

The following code does nothing but write a column from the database to a text file a row at a time. I was just trying that to see if it worked.

I get the error "Invalid use of NULL" on the line strMake = MyRecSet("Make")

What have I done wrong? The path to the database is correct, the name of the table is correct and the name of the column is correct.

Thanks

Dim MyConn As ADODB.Connection
Dim MyRecSet As ADODB.Recordset
Dim strMake As String



Private Sub Form_Load()
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Parts data\evparts.mdb;"
MyConn.open

Set MyRecSet = MyConn.Execute("SELECT * FROM parts")



Open "c:\testlist.txt" For Output As #1
Do Until MyRecSet.EOF
strMake = MyRecSet("Make")

Print #1, strMake
MyRecSet.MoveNext
Loop
Close #1
MyConn.Close
End Sub

Reply With Quote
  #5  
Old August 10th, 2003, 03:31 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,717 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 40 m 34 sec
Reputation Power: 688
Probably you have a record that doesn't have any value for MyRecSet("Make")

Try doing some tests on strMake, like If IsNull(strMake) then strMake = ""

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > VBA Access. How do I open a database?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway