Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

From array to table

Posted on 2000-03-07
3
Medium Priority
?
155 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 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 …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

688 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