We help IT Professionals succeed at work.

saving part of database

majala
majala asked
on
161 Views
Last Modified: 2010-04-30
What would be easiest way to save only part of database in different name? Databases type is Dbase IV.

If I have a recordset which has all the datas from database and then user gives some range of database and a new databases name.

Let's say that database has datas from 1/1/1998 to 19/8/1998 and then user wants to do new database which has only datas from 1/1/1998 to 31/1/1998 and give it a new name. Those databases isn't always similar.

Do I have to open a new recordset for that given range of dates and somehow try to save it or create new database and somehow try to copy all fields to it and then try copy datas to it??  
 
 
   
 
Comment
Watch Question

Commented:
You can create a new query to populate your new db

INSERT INTO target [IN externaldatabase] [(field1[, field2[, ...]])]
SELECT [source.]field1[, field2[, ...]
FROM tableexpression


dbs.Execute "INSERT INTO Customers SELECT * FROM [New Customers];"
            
      

Author

Commented:
That database isn't always same kind of, so I don't know how many fields there is (does that your comment work anyway?).
I guess I have to create that new database before I can populate it?

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
This gives me an error, that "Sub of function not defined"
   tblTableDefObj.Name = StripOwner(vToName)
and this gives an error, that "Object required"
  Set tblTableDefObj = gdbCurrentDB.CreateTableDef()

Author

Commented:
This gives me an error, that "Sub or function not defined"
   tblTableDefObj.Name = StripOwner(vToName)
and this gives an error, that "Object required"
  Set tblTableDefObj = gdbCurrentDB.CreateTableDef()

Commented:
gdbCurrentDB should be your database.
 
NB : you should load the Visdata Sample, All is there.

here is the function StripOwner:

'------------------------------------------------------------
'strips the owner off of ODBC table names
'------------------------------------------------------------
Function StripOwner(rsTblName As String) As String

  If InStr(rsTblName, ".") > 0 Then
    rsTblName = Mid(rsTblName, InStr(rsTblName, ".") + 1, Len(rsTblName))
  End If
  StripOwner = rsTblName

End Function

Author

Commented:
There is in CopyStruct-function this function call and in my program there is users new databasename in variable vToName.

  tblTableDefObj.Name = StripOwner(vToName)

Why that StripOwner function returns string after dot? When user gives new databases name MyDB.dbf then result of StripOwner is dbf and result of hole CopyStruct is dbf.dbf

I changed StripOwner like this and now I think it works like it should (user gives new databases name "MyDB.dbf", result of StripOwner is "MyDB" and result of hole CopyStruct is
"MyDB.dbf")

   rsTblName = Mid(rsTblName, 0,InStr(rsTblName, ".") - 1)

Or is there something I don't get?

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.