mostafa10922
+ Looks like you are attempting to connect to an external database and transfer data into the Access database?
+ Are you attempting to use .Net or VB instead of VBA
within an Access database - these will not directly work in VBA procedures - did you borrow the code from somewhere? you need to post either the code you are using or the link to the site you borrowed the code from so we can take a look.
OleDbDataAdapter
-isn't standard in Access VBA
OleDbCommandBuilder
- isn't standard in Access VBA
If you are trying to use .Net then we may need to move your thread so that people more acquainted with it will see your question.
+ Unless what you have listed are only the titles of custom VBA code then what you have will not work in an Access database - BTW:
Connection Strings can be found here for the OleDbDataAdapter you need to verify that "CON1" is properly formed string.
+ Pull this out into a string variable:
strSQL = "(select * from EMP where SITE like '%" & ComboBox1.Text & "%'"
Now you can insert a
debug.print strSQL
to make sure the string is properly formed, (same for your CON1 )- 90% of issues are malformed strings when used directly within a function or subroutine call.
I fixed a few spacing issues here; however, I don't have your system so I can't go any further than that and without more information on your code to see if the connection is being properly called that's as much help as you could wish for with the string.
"%" hmmm, unless your access database is set for ansi92 access will not recognize this as a wild card and I cannot tell what database you are attempting to connect to so no help there... at some point you should try " * " for the wildcard. I've only found the " % " to work for pass through queries to Large Factor Databases such as MySQL, SQLServer,
+ IF you are working from
within Access then you should also check to that your code is compiling properly - reopen the VBA editor
Menu>Debug>Compile
Fix any errors, it must compile without errors before we can go any further.