Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

From array to table

Posted on 2000-03-07
3
Medium Priority
?
156 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

824 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