Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 31st, 2005, 11:53 AM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default Built-in functions !

Hi everybody !
Is there a Function PopulateTable() in access ? If true i need help
how to use it. If false how to populate a table with data from
a variant array (varData) both in a Databse ?
Any help will be welcome.
P.

  #2 (permalink)  
Old January 31st, 2005, 12:06 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

There may be a similar function, but I'll leave that to others to comment on. I have always set up a connection, and then build and run SQL strings to accomplish this. I used the following code to create a table called RBRVS and then insert data into it from another table. There is some additional logic included, but this should be able to give you a basic idea. Yell if it needs more clarification.

Mike

dim cn as ADODB.Connection
dim rs as ADODB.Recordset

Set cn = Application.CurrentProject.Connection
Set rs = New ADODB.Recordset

'This checks to see if the table exists
    strSQL = "SELECT Count(*) AS Present FROM MSysObjects WHERE Name = 'RBRVS' AND Type = 1"

    rs.Open strSQL, cn

'If the table exists, we need to drop it
    If rs.Fields("Present") = 1 Then
        strSQL = "DROP TABLE RBRVS"
        cn.Execute strSQL
    End If

    strSQL = "CREATE TABLE RBRVS "
    strSQL = strSQL + "(Code TEXT(5) NOT NULL, Description TEXT(100) NOT NULL, "
    strSQL = strSQL + "WorkRVU DOUBLE, PracticeRVU DOUBLE, MalpracticeRVU DOUBLE, "
    strSQL = strSQL + "TotalRVU TEXT(15), Amount CURRENCY)"

    cn.Execute strSQL

    Set rs = New ADODB.Recordset

    strSQL = "SELECT * FROM " + OtherTable
    rs.Open strSQL, cn
    rs.MoveFirst
    While rs.EOF = False
        strSQL = "INSERT INTO RBRVS VALUES ( '"
        strSQL = strSQL & rs.Fields("Anesthesia_Code") & "', '" & rs.Fields("Description") & "', "
        strSQL = strSQL & "NULL, NULL, NULL, '" & rs.Fields("Anesthesia_Base_Unit") & "', "
        If IsNumeric(rs.Fields("Anesthesia_Base_Unit")) Then
            strSQL = strSQL & (rs.Fields("Anesthesia_Base_Unit") * ANESCF) & ")"
        Else
            strSQL = strSQL & "0.00)"
        End If
        cn.Execute strSQL
        rs.MoveNext
    Wend

set rs = Nothing
set cn = Nothing




Mike
EchoVue.com
  #3 (permalink)  
Old January 31st, 2005, 12:21 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Much thanks Mike !
I'll work on it.
P.

  #4 (permalink)  
Old January 31st, 2005, 01:32 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's too much sand for my little truck.
Hope someone will comment about a buil-in function on Access2002.
Maybe the coin will drop as the time goes by.
Much thanks again Mike.
P.

  #5 (permalink)  
Old January 31st, 2005, 03:57 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Can you tell me more about your problem? Specifically, where are you getting the data to populate the array? What is the structure of the array? Where is the data going? Table structure, etc? Is it all in the same database? Is it an mbd, an adp, etc?

I can help you build arrays and send the data to the appropriate table. I do this all the time.


mmcdonal
  #6 (permalink)  
Old February 1st, 2005, 06:16 AM
Friend of Wrox
 
Join Date: Aug 2004
Location: , , .
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here it goes !
It's a long story.
I have a good form data entry in VB6 and i have a good report on Access2002.
My target is to send data from form VB6 to report. I was faced to several
problems like:
1. The form sends data to tb1 that must have columns transposed to fit
on the report. So far so good, because i've just have had help from
JpJoe who taught me how to do the transpose in access.
2. The data entry form is for saving monthly informations about related work-days and some dozens employees. My first thought was to use the function
GetRows() to fill an array with data from tb1 and as the array (literature
keeps saying) can be retrieved randomly, to retrieve the data from the
array transposing columns and rows into a table tb2 (row source from the
access report). Tb1 and tb2 are on a Db.mdb. I have had a hard time trying
to retrieve data from the array to Tb2. Tb2 is created with a SQL string.
I have tried to use a function PopulateTable to send data to Tb2 from the
array.There is a p2p Topic about this but i have been lost on the road.
3.If i suppose that step 2 is solved, i will be on step 3 that will have
to do with manipulating the data in Tb2, so that i could have one employee
per page on the report.
Thanks for ur care.
Ask me for more informations.
Regards P.



Similar Threads
Thread Thread Starter Forum Replies Last Post
enabling controls built in XSLT and imported charles95621 ASP.NET 2.0 Professional 0 July 15th, 2007 02:49 PM
Payraise Calculator built with this book! coders4hire BOOK: Professional Ajax ISBN: 978-0-471-77778-6 3 October 23rd, 2006 12:14 PM
Any built-in component in C# to FTP? peri C# 2 December 16th, 2004 10:03 PM
how can i built my forum of open source khach Beginning PHP 3 July 21st, 2004 08:17 AM
Define events in COM built in .NET roy VS.NET 2002/2003 1 October 22nd, 2003 11:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.