Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Database App Creates Own Data Table?

Posted on 1999-07-13
9
Medium Priority
?
199 Views
Last Modified: 2010-05-02
Please provide code for a Visual Basic Application to
1. Determine if a table exists.  
2. If not, I want it to create the table
3. In both cases it then Opens the table
4. Should then easily - add - edit - delete records
Sounds moderate but lets make it tough and give full expert points for what I assume will be a great useful answer!

PLEASE DONT redirect me to another question/answer# but rather paste actual Code here!  THANK YOU EXPERTS!
0
Comment
Question by:zeuskrell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 

Author Comment

by:zeuskrell
ID: 1524488
Make it an actual database table not a text table please
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1524489
db is the database(dao) object, or the connection object(ado)

On Error Resume next
db.Execute "CREATE TABLE table1 FIELDS(Field1 TEXT, Field2 LONG);"
On error goto 0

Dim rs as recordset
rs.open "SELECT * FROM table1"

'do whatever with recordset

0
 

Author Comment

by:zeuskrell
ID: 1524490
This is a four part question please.  
You've provided a possible very brief answer to only question #2 of the four points requested.
:(

We want to determine if we need to create a table and then also open and add something in the newly created table please.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:zeuskrell
ID: 1524491
Maybe I am just missing it and need more explanation.  Do the error traps prevent it from overwriting an existing table or getting an erro creating a table IF it exists already?

What I was really hoping for is a module which I could paste into VB5 or VB6 and run it and when I run the first time it creates and adds a record to the table and the second time it adds another record to the table.  This doesn't seem to do that.  If you could just give me a tiny bit more code to make it a complete working module.
0
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 800 total points
ID: 1524492
The error trapping code is to prevent an error in case a table already exist. It won't be overwrited at any case. To add a new record, use:

rs.open "SELECT * FROM table1"
rs.AddNew
rs!FieldName1="Value1"
rs!FieldName2="Value2"
...
rs.Update

 
0
 
LVL 1

Expert Comment

by:rayford
ID: 1524493
OK Thanks!  That works!
0
 
LVL 1

Expert Comment

by:rayford
ID: 1524494
You should give him credit I believe.  I tried it and worked beautifully
0
 
LVL 1

Expert Comment

by:rayford
ID: 1524495
OK Thanks credit given
0
 

Author Comment

by:zeuskrell
ID: 1524496
Yes agreed good answer

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question