p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access (http://p2p.wrox.com/forumdisplay.php?f=18)
-   -   Built-in functions ! (http://p2p.wrox.com/showthread.php?t=24808)

penta January 31st, 2005 11:53 AM

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.

echovue January 31st, 2005 12:06 PM

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.


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 = 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
    While rs.EOF = False
        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) & ")"
            strSQL = strSQL & "0.00)"
        End If
        cn.Execute strSQL

set rs = Nothing
set cn = Nothing


penta January 31st, 2005 12:21 PM

Much thanks Mike !
I'll work on it.

penta January 31st, 2005 01:32 PM

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.

mmcdonal January 31st, 2005 03:57 PM

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.


penta February 1st, 2005 06:16 AM

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.

All times are GMT -4. The time now is 01:03 PM.

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