Solved

From array to table

Posted on 2000-03-07
3
151 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
[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
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
samopal earned 100 total points
ID: 2592919
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
ID: 2594730
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
ID: 2596100
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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