error message

yoonie_85
10-27-2004, 01:14 PM
Hello :)

i'm running my module, and keep getting a pop error window that reads something along of the lines of "MSACCESS.exe has generated errors. Windows will now plose the program".

I can't seem to find what's wrong with what i'm doing. I also tested it with smaller table and it work perfectly. someone pleeease help. thanks in advance!

this is my code:
Sub Create()

Dim OriginalRS As Recordset
Dim DataRS As Recordset
Dim CustCode, PremCode, Cust2Code, Prem2Code As Long
Dim found As Boolean
Dim NumRecords As Long
Dim aRecord As Long

Set OriginalRS = CurrentDb.OpenRecordset("Res_phone", dbOpenDynaset)
Set DataRS = CurrentDb.OpenRecordset("NotInCustListLess18000", dbOpenDynaset)

CustCode = DataRS!CustCode
PremCode = DataRS!PremCode
Cust2Code = OriginalRS!Cust_Code
Prem2Code = OriginalRS!Prem_Code
aRecord = 1
OriginalRS.MoveLast
NumRecords = OriginalRS.RecordCount
OriginalRS.MoveFirst
found = False

Do Until DataRS.EOF
Do Until found = True Or OriginalRS.EOF
CustCode = DataRS!CustCode.Value
PremCode = DataRS!PremCode.Value
Cust2Code = OriginalRS!Cust_Code.Value
Prem2Code = OriginalRS!Prem_Code.Value
If CustCode = Cust2Code And PremCode = Prem2Code Then
found = True
Exit Do
Else
If aRecord < NumRecords Then
aRecord = aRecord + 1
OriginalRS.MoveNext
Else
aRecord = 0
Exit Do
End If
End If
Loop

If found = True Then
DataRS.Edit
DataRS!PhoneNumber = OriginalRS!PhoneNumber
DataRS!AreaCode = OriginalRS!AreaCode
DataRS!Extention = OriginalRS!Extention
DataRS.Update
End If

DataRS.MoveNext
aRecord = 1
OriginalRS.MoveFirst
found = False

Loop

DataRS.Close
Set DataRS = Nothing
OriginalRS.Close
Set OriginalRS = Nothing


End Sub

ed_creed
10-27-2004, 03:32 PM
have you stepped through it to find out what line it errors on?

loquin
10-27-2004, 03:45 PM
Don't know if it will have any effect, but declare your variables

Dim CustCode as Long, PremCode as Long, Cust2Code as Long, Prem2Code As Long
(The first three would be declared as variants with your statement...)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum