Solved

From array to table

Posted on 2000-03-07
3
147 Views
Last Modified: 2010-05-02
I Filledup two 2.dimensinal arrays.I wont to check value in several col. of first array  wiht value in a second col. of second array and if value the same I want to replace value from first with value in second array.I have pice of code and I am not sure is it Ok. After I did this I wont to fillup access table with first array. Whent  I try this I am geting error: trying to assaign Null value to variable which is not variant type. I am not sure where I am making mistake. I Checke table filds types to be sure it looks ok.
Here is pice of code which I am using
Dim PullPatientSpec(5950, 23) As Variant
Dim Pullcode(344, 4) As Variant

Dim rowp As Integer
Dim colp As Integer
Dim rowc As Integer
Dim colc As Integer

For rowp = 0 To 5950
For colp = 4 To 14
    For rowc = 0 To 344
    colc = 1
       
        If Pullcode(rowc, colc) = PullPatientSpec(rowp, colp) Then
            PullPatientSpec(rowp, colp) = Pullcode(rowc, colc + 1)
         End If
   
    Next rowc
Next colp
Next rowp

And Part for fillup access table
Set rsTemp = dbDatabase.OpenRecordset("TempPatientSpecific", dbOpenDynaset)

rsTemp.AddNew
Dim PullPatientSpec(5950, 23) As Variant
Dim rowp As Integer
Dim colp As Integer

For rowp = 0 To 5950
rsTemp.AddNew
For colp = 0 To 23
rsTemp.Fields(colp) = PullPatientSpec(rowp, colp)

Next colp
rsTemp.Update
Next rowp

0
Comment
Question by:backroads
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
samopal earned 100 total points
Comment Utility
It's a common mistake - try to assign NULL value to Access field. Change the line rsTemp.Fields(colp)=... to
If not IsNull(PullPatientSpec(rowp, colp) Then rsTemp.Fields(colp) = PullPatientSpec(rowp, colp)


HTH

0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Wait a second samopal.. read the code again.. backroads is looping too many times through the code for BOTH tables!!!

Dim PullPatientSpec(5950, 23) As Variant

The PullPatient Spec is defined as 5950 rows.. since VB arrays (unless explicitly overridden) are zero based, that means index values can only be in the range of 0 to 5949.. as such.. the FOR loop statement he uses..

For rowp = 0 To 5950

is definitely going to error out because he is exceeding the end of the array on the last pass.

Backroads.. adjust your loops accordingly, k?





0
 
LVL 9

Expert Comment

by:samopal
Comment Utility
To wsh2: Look at Backroad's original message:
<I try this I am geting error: trying to assaign Null value to variable
What you found is a mistake, but it's ahead :-)))
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
vba find the last empty column 10 81
VBA color chart bars 12 64
Problem to skip loop 6 49
How to debug this code 7 49
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now