We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Access VBA Type mismatch

Murray Brown
Murray Brown asked
on
Medium Priority
606 Views
Last Modified: 2008-02-01
Hi

I am getting a type mismatch error on trying to call one function from another. I am passing three strings
The two procedures are below....

Sub Import_Tables_And_Convert_to_Internal_Table()

     Call Import_Table_from_another_AccessDB ("G:\GFI_LoanTrading_Support\Production_Applications\Leveraged_Fin_Database\Application\Leverage_Finance_Rec_Tool.mdb", "t_LNK_BC_Fidessa", "t_LNK_BC_Fidessa")
 
     
End Sub

Sub Import_Table_from_another_AccessDB(ByVal sPathAndFile As String, ByVal sSourceTable As String, ByVal sDestinationTable As String)

    DoCmd.TransferDatabase acImport, sPathAndFile, acTable, sSourceTable, sDestinationTable

End Sub
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Hi murbro,

   DoCmd.TransferDatabase acImport, , sPathAndFile, acTable, sSourceTable,  sDestinationTable

(Extra comma)

Pete

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Top Expert 2006
Commented:
2nd parameter needs database type
e.g.

    DoCmd.TransferDatabase acImport, "Microsoft Access", sPathAndFile, acTable, sSourceTable, sDestinationTable
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Thanks Pete. I clearly didn't get a strong enough coffee this morning
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Sorry rockiroads - I need to free up the points to give you half
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
I have asked support to help me split the points
CERTIFIED EXPERT
Top Expert 2006

Commented:
Hi Murray, no worries, Pete was first off the mark anyway
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
but I tried without "Microsoft Access" and it didn't work. I f it should have then please let me
know, otherwise will just reallocate
CERTIFIED EXPERT
Top Expert 2006

Commented:
So did it work when u specified "Microsoft Access" ?
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Yes
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
......thanks
CERTIFIED EXPERT
Top Expert 2006

Commented:
I assumed when not specfying the database type, it picks the default. The default one may not be "Microsoft Access" in this case. Pete would u know?

I just tried this as a test as I got an error, but it's not a datatype mismatch
"the type isnt an installed database type or doesnt support the operation you chose"

So for me "Microsoft Access" is not the default type.

CERTIFIED EXPERT
Top Expert 2006

Commented:
and obviously not for u either. So perhaps u have to specify the database type.
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
I would also assume that....still sounds strange though
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
yes I do have to specify that. Is it perhaps a Microsoft Windows setting that may be on my bank's network?
CERTIFIED EXPERT
Top Expert 2006

Commented:
No, I wouldnt think so. I think u just have to specify the database type. The help does not mention any type of Default value, if there was, it would of mentioned it.

the datatype mismatch error was due to acTable

acTable is numeric and has a value of 0
u was passing in sSourceTable (string) when u should of been passing acTable (numeric) due to parameters misaligned.

Adding the 2nd comma aligned the parameters so that removes your original error but it appears u still have to specify the database type.
CERTIFIED EXPERT

Commented:
Help says states that the database type parameter is optional and that Access is the default type .
This appears to be a travesty of the truth as far as A2003 goes.  I haven't tried on anything else.
Can't find anyone reporting it as a problem, which is surprising.

Maybe significantly, MSDN does not state it is optional, although still says Access is the default type ( ? which means what, if it is not optional)

Anyway, it appears the database type is necessary.

Pete


Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Yes so I should split the points because half the job was putting the extra coom ain and the other was "Microsoft Access"
CERTIFIED EXPERT
Top Expert 2006

Commented:
Pete, Im running A2003, so perhaps this version the default type is summat else?
CERTIFIED EXPERT

Commented:
Which help are you looking at Rocki?

A2003 help file =:

DatabaseType   Optional Variant. A string expression that's the name of one of the types of databases you can use to import, export, or link data.

Types of databases:
Microsoft Access (default)
Jet 2.x
Jet 3.x
dBase III
dBase IV
dBase 5.0
Paradox 3.x
Paradox 4.x
Paradox 5.x
Paradox 7.x
ODBC Databases
WSS

Pete

Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
I am also running A2003
CERTIFIED EXPERT
Top Expert 2006

Commented:
dunno now, bugger, what the hell was I reading. I missed the Optional variant bit as I just saw that now.

So if Access is the default why aint it working then, a bug perhaps or help files incorrect?
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
...interesting
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Reallocated
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.