angeltink99
New member
- Local time
- Today, 08:21
- Joined
- Aug 16, 2011
- Messages
- 6
I have a monster of a database at work and needed to adjust a bit of the program language. I am now getting a run-time error, but only some of the time!! To premise this, the code is all part of a process where we import data off a 3rd party disc, format it through access to what we need per our access requirements, then append the data to our table. The import is anywhere from 60 to 700 rows into our table numbering in the thousands. I uploaded 3 chunks of data without running into the error. Then, I tried another (60 records) chunk and it hit this error. Went back a tried a previous chunk and it still worked. I'm not sure why it is erroring out here, and why only some of the time. Can anyone please shed some light on this? And you have to talk like I'm 2, as I have very little background and am learning as I go.
Here is the code. The portion that breaks is in red!
Private Sub Form_Close()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim dbs As Database, rst As DAO.Recordset
Dim strsql As String
Set dbs = CurrentDb
Msg = "Do You Want To Continue With Import Process?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Import Decision"
Help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes. IF PROMPT 1
Set dbs = CurrentDb
DtImportTBL_CD_ATT_DATA = Date$
strsql = "SELECT [TBL_CD_AT&T_DATA_ADJ].*, [TBL_CD_AT&T_DATA_ADJ].[Billing Number] FROM [TBL_CD_AT&T_DATA_ADJ] LEFT JOIN ETSBLOG ON [TBL_CD_AT&T_DATA_ADJ].[Billing Number] = ETSBLOG.BILLNUM WHERE (((ETSBLOG.BILLNUM) Is Null) AND (Not Left([TBL_CD_AT&T_DATA_ADJ]![Billing Number],3)= 960));"
Set rst = dbs.OpenRecordset(strsql)
If rst.RecordCount > 0 Then
msgtbl = "You Have Invoice Records Without Bill Numbers"
MsgBox msgtbl
StrTBL_CD_ATT_DATA_NoBILLNUM_Cnt = rst.RecordCount
DoCmd.OpenQuery "8A_QRY_TBL_CD_ATT_DATA_ADJ Without Matching ETSBLOG"
rst.Close
Set dbs = Nothing
DoCmd.OpenReport "RPT_TBL_CD_ATT_DATA_ADJ_NON_MATCH_ETSBLOG", acViewPreview
Else
msgtbl = "You Have No Authorized Amounts Differences."
MsgBox msgtbl
DoCmd.OpenQuery "9D_Qry_Chk_Dup_ETSINV_TBL_CD_ATT_DATA_ADJ"
strsql = "SELECT * FROM TBL_CD_ATT_DATA_ADJ_DUPS"
Set rst = dbs.OpenRecordset(strsql)
If rst.EOF = False Then
rst.MoveLast
End If
If rst.RecordCount > 0 Then
StrTBL_CD_ATT_DATA_DupRecs = rst.RecordCount
msgtbl = "IMPORT ERROR -> You Have These Records Already In The ETSINV Table!"
MsgBox msgtbl
DoCmd.OpenReport "RPT_DUP_ATT_DATA_ADJ_ALREADY IN ETSINV", acViewPreview
Else
msgtbl = "You Have No Duplicate ETSINV Import Errors! Appending TBL_CD_ATT_DATA_ADJ Records To ETSINV Table"
MsgBox msgtbl
DoCmd.OpenQuery "9F_Qry_Map_CD_ATT_ADJ_ETSINV"
Set dbs = CurrentDb
strsql = "SELECT [TBL_CD_AT&T_DATA_ADJ].* FROM [TBL_CD_AT&T_DATA_ADJ]"
Set rst = dbs.OpenRecordset(strsql)
If rst.EOF = False Then
rst.MoveLast
End If
StrTBL_CD_ATT_DATA_InCount = rst.RecordCount
rst.Close
Set dbs = CurrentDb
strsql = "SELECT * FROM TBL_Import_Status"
Set rstStatus = dbs.OpenRecordset(strsql)
End If
Set dbs = Nothing
End If
Set dbs = Nothing
Else ' User chose No. ELSE PROMPT 1
msgtbl = "Import Process Is Stopped!"
MsgBox msgtbl
End If ' ENDIF PROMPT 1
End Sub
Here is the code. The portion that breaks is in red!
Private Sub Form_Close()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim dbs As Database, rst As DAO.Recordset
Dim strsql As String
Set dbs = CurrentDb
Msg = "Do You Want To Continue With Import Process?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Import Decision"
Help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes. IF PROMPT 1
Set dbs = CurrentDb
DtImportTBL_CD_ATT_DATA = Date$
strsql = "SELECT [TBL_CD_AT&T_DATA_ADJ].*, [TBL_CD_AT&T_DATA_ADJ].[Billing Number] FROM [TBL_CD_AT&T_DATA_ADJ] LEFT JOIN ETSBLOG ON [TBL_CD_AT&T_DATA_ADJ].[Billing Number] = ETSBLOG.BILLNUM WHERE (((ETSBLOG.BILLNUM) Is Null) AND (Not Left([TBL_CD_AT&T_DATA_ADJ]![Billing Number],3)= 960));"
Set rst = dbs.OpenRecordset(strsql)
If rst.RecordCount > 0 Then
msgtbl = "You Have Invoice Records Without Bill Numbers"
MsgBox msgtbl
StrTBL_CD_ATT_DATA_NoBILLNUM_Cnt = rst.RecordCount
DoCmd.OpenQuery "8A_QRY_TBL_CD_ATT_DATA_ADJ Without Matching ETSBLOG"
rst.Close
Set dbs = Nothing
DoCmd.OpenReport "RPT_TBL_CD_ATT_DATA_ADJ_NON_MATCH_ETSBLOG", acViewPreview
Else
msgtbl = "You Have No Authorized Amounts Differences."
MsgBox msgtbl
DoCmd.OpenQuery "9D_Qry_Chk_Dup_ETSINV_TBL_CD_ATT_DATA_ADJ"
strsql = "SELECT * FROM TBL_CD_ATT_DATA_ADJ_DUPS"
Set rst = dbs.OpenRecordset(strsql)
If rst.EOF = False Then
rst.MoveLast
End If
If rst.RecordCount > 0 Then
StrTBL_CD_ATT_DATA_DupRecs = rst.RecordCount
msgtbl = "IMPORT ERROR -> You Have These Records Already In The ETSINV Table!"
MsgBox msgtbl
DoCmd.OpenReport "RPT_DUP_ATT_DATA_ADJ_ALREADY IN ETSINV", acViewPreview
Else
msgtbl = "You Have No Duplicate ETSINV Import Errors! Appending TBL_CD_ATT_DATA_ADJ Records To ETSINV Table"
MsgBox msgtbl
DoCmd.OpenQuery "9F_Qry_Map_CD_ATT_ADJ_ETSINV"
Set dbs = CurrentDb
strsql = "SELECT [TBL_CD_AT&T_DATA_ADJ].* FROM [TBL_CD_AT&T_DATA_ADJ]"
Set rst = dbs.OpenRecordset(strsql)
If rst.EOF = False Then
rst.MoveLast
End If
StrTBL_CD_ATT_DATA_InCount = rst.RecordCount
rst.Close
Set dbs = CurrentDb
strsql = "SELECT * FROM TBL_Import_Status"
Set rstStatus = dbs.OpenRecordset(strsql)
End If
Set dbs = Nothing
End If
Set dbs = Nothing
Else ' User chose No. ELSE PROMPT 1
msgtbl = "Import Process Is Stopped!"
MsgBox msgtbl
End If ' ENDIF PROMPT 1
End Sub