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

x
?
Solved

Access VBA Type mismatch

Posted on 2006-11-08
24
Medium Priority
?
556 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
0
Comment
Question by:Murray Brown
[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
  • 12
  • 8
  • 3
24 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 1000 total points
ID: 17896781
Hi murbro,

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

(Extra comma)

Pete
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 1000 total points
ID: 17896787
2nd parameter needs database type
e.g.

    DoCmd.TransferDatabase acImport, "Microsoft Access", sPathAndFile, acTable, sSourceTable, sDestinationTable
0
 

Author Comment

by:Murray Brown
ID: 17896792
Thanks Pete. I clearly didn't get a strong enough coffee this morning
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:Murray Brown
ID: 17896810
Sorry rockiroads - I need to free up the points to give you half
0
 

Author Comment

by:Murray Brown
ID: 17896825
I have asked support to help me split the points
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17896886
Hi Murray, no worries, Pete was first off the mark anyway
0
 

Author Comment

by:Murray Brown
ID: 17896914
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
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17896968
So did it work when u specified "Microsoft Access" ?
0
 

Author Comment

by:Murray Brown
ID: 17896973
Yes
0
 

Author Comment

by:Murray Brown
ID: 17896974
......thanks
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17896986
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.

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17896996
and obviously not for u either. So perhaps u have to specify the database type.
0
 

Author Comment

by:Murray Brown
ID: 17897000
I would also assume that....still sounds strange though
0
 

Author Comment

by:Murray Brown
ID: 17897007
yes I do have to specify that. Is it perhaps a Microsoft Windows setting that may be on my bank's network?
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17897120
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.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 17897130
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


0
 

Author Comment

by:Murray Brown
ID: 17897136
Yes so I should split the points because half the job was putting the extra coom ain and the other was "Microsoft Access"
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17897242
Pete, Im running A2003, so perhaps this version the default type is summat else?
0
 
LVL 77

Expert Comment

by:peter57r
ID: 17897276
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

0
 

Author Comment

by:Murray Brown
ID: 17897326
I am also running A2003
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17897413
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?
0
 

Author Comment

by:Murray Brown
ID: 17897449
...interesting
0
 

Author Comment

by:Murray Brown
ID: 17912903
Reallocated
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

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