Solved Generate error mesage for import errors (1 Viewer)

Jimal

Member
Local time
Today, 14:45
Joined
Sep 29, 2020
Messages
60
Hello saviors..

I'm importing tables into my access database by a user form
however I understand there are some errors -Type Conversion Failure
these errors are stored in a new table without my knowledge - I mean without any error prompt

Can you please suggest a code to pop an error message If one such error table is generated upon imporing my table...

thanks in advance
 

Isaac

Lifelong Learner
Local time
Today, 02:15
Joined
Mar 14, 2017
Messages
8,774
You could add a line of code to check if the name of the import table exists
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:15
Joined
Oct 29, 2018
Messages
21,447
Maybe @Isaac meant to check for tables with "ImportErrors" in the name.

Just a guess...
 

Jimal

Member
Local time
Today, 14:45
Joined
Sep 29, 2020
Messages
60
well @theDBguy seems like an idea... can u mind helping with a code as im not an expert in the VBA code
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:15
Joined
Oct 29, 2018
Messages
21,447
well @theDBguy seems like an idea... can u mind helping with a code as im not an expert in the VBA code
Hi. Sorry, not in front of a computer now to write good code for you; but, try searching for the keyword "TableExists." I think I've seen a sample function with that name.

I can post something tomorrow, if you still need one.

Sent from phone...
 

Jimal

Member
Local time
Today, 14:45
Joined
Sep 29, 2020
Messages
60
thank you @theDBguy
I tried some but in vain
I have a error table generate by name C_TERMINATIOSN$_ImportErrors
but when I used a public function as below
-----------------------------------------------------------------------------------
Public Function ifTableExists(tblName As String) As Boolean

If DCount("[Name]", "MSysObjects", "[Name] = '" & tblName & "'") = 1 Then

ifTableExists = True

End If

End Function
-----------------------------------------------------------------------------------

and called the function as
call ((C_TERMINATIOSN$_ImportErrors))

it is showing syntax errors for invalid charectors etc.,

pls help
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:15
Joined
May 7, 2009
Messages
19,226
If there is a wizard on the import.
Try to follow it and Correctly Identify the Datatype of each columns.
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:15
Joined
Sep 21, 2011
Messages
14,217
thank you @theDBguy
I tried some but in vain
I have a error table generate by name C_TERMINATIOSN$_ImportErrors
but when I used a public function as below
-----------------------------------------------------------------------------------
Public Function ifTableExists(tblName As String) As Boolean

If DCount("[Name]", "MSysObjects", "[Name] = '" & tblName & "'") = 1 Then

ifTableExists = True

End If

End Function
-----------------------------------------------------------------------------------

and called the function as
call ((C_TERMINATIOSN$_ImportErrors))

it is showing syntax errors for invalid charectors etc.,

pls help
Well for a start I would expect you would have to call the function as
Code:
Call ("C_TERMINATIOSN$_ImportErrors")

but I would hazard a guess the table is called C_TERMINATIOSN, in the system table, even if it looks like it has been spelt incorrectly.?
You would need to see exactly what is stored in MSysobject for that file?

I am going to go to my grave saying this :), but 'Walk though the code in the debugger to see what it is ACTUALLY doing, not what you THINK it is doing'.
 

Jimal

Member
Local time
Today, 14:45
Joined
Sep 29, 2020
Messages
60
Hi @Gasman

You are right the actual imported file / stored table name is C_TERMINATIOSN ,whereas the generated error table is C_TERMINATIOSN$_ImportErrors

I should need to check for the error table right...that's what I did
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:15
Joined
Sep 21, 2011
Messages
14,217
Hi @Gasman

You are right the actual imported file / stored table name is C_TERMINATIOSN ,whereas the generated error table is C_TERMINATIOSN$_ImportErrors

I should need to check for the error table right...that's what I did
What is it stored as in the system table though? as that is where you are looking?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:15
Joined
May 7, 2009
Messages
19,226
use the wizard.
this will give a chance to set the Column's Datatype.
if you have mixed data in a column, like numeric and text, access might
interpret the column as numeric. therefore some of the records as not converted if
they have text.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 10:15
Joined
Feb 19, 2013
Messages
16,601
and called the function as
call ((C_TERMINATIOSN$_ImportErrors))

it is showing syntax errors for invalid charectors etc.,

would think a) you don't want to use call since you need to return a value and b) you need to specify the name of your function. i.e. you need something like this

Code:
if  ifTableExists("C_TERMINATIOSN$_ImportErrors") then
   'do something
else
   'do something else
end if
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:15
Joined
Oct 29, 2018
Messages
21,447
thank you @theDBguy
I tried some but in vain
I have a error table generate by name C_TERMINATIOSN$_ImportErrors
but when I used a public function as below
-----------------------------------------------------------------------------------
Public Function ifTableExists(tblName As String) As Boolean

If DCount("[Name]", "MSysObjects", "[Name] = '" & tblName & "'") = 1 Then

ifTableExists = True

End If

End Function
-----------------------------------------------------------------------------------

and called the function as
call ((C_TERMINATIOSN$_ImportErrors))

it is showing syntax errors for invalid charectors etc.,

pls help
Hi. I go to bed and wake up to a lot of activities here. :)

I would agree with @CJ_London on this one. Give it a try and let us know how it goes. Cheers!
 

Isaac

Lifelong Learner
Local time
Today, 02:15
Joined
Mar 14, 2017
Messages
8,774
Try this.

Code:
Function TableExists(strName As String) As Boolean
Dim td As DAO.TableDef
On Error Resume Next
Set td = CurrentDb.TableDefs(strName)
If Err.Number <> 0 Then
    TableExists = False
Else
    TableExists = True
End If
End Function
INI:
If TableExists("C_TERMINATIOSN$_ImportErrors")=True then
  msgbox "File imported with errors, please review",vbinformation,"  "
end if
 

Users who are viewing this thread

Top Bottom