p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Microsoft Office > Access and Access VBA > Access
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 29th, 2007, 10:10 PM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Linked SQL table doesn't show up as control source

Alright. Here's the scoop:

There's 2 MDB files. One is chock full o' tables.
The other is mostly VBA and forms, and was thrown together by, from what I can ascertain from the existing "programming", drunken squirrels with arthritis.

Now, the "forms" mdb file, which we'll call frontend.mdb for sake of clarity, had the form from which I'd LIKE to execute a SQL "INSERT INTO" command, using data from the form, and several other calculations.

the "tables" mdb file (we'll call it backend.mdb) has the table link to the DSN object for the MYSQL database.

I have constructed a SQL query that, although it works in the "immediate" window of VBA (when fed the proper data in the VALUES() area) and also is given the exact same data when run from a form (I did a MsgBox (strSQLQuery) just to see that the values were right) and.....
NOTHING HAPPENS.

No error message, no ding, no "uhoh!" no information, no nothin'.

This is actually how this little monstrosity behaves if I so much as misconstruct a msgbox, so that's not the surprising part.

What IS surprising is that I don't see the mySQL linked table if I try to, oh, say, map a textbox to a field in the database.

I know they've got some code somewhere to connect frontend.mdb to backend.mdb but it ain't exactly doing a good job of picking up on the new table, and I'm rapidly getting tired of guessing where they've squirreled it away sooo....

If ANYONE out there knows how to connect to a linked SQL table in ONE mdb file from in an onclick() event in ANOTHER mdb file and do a SQL type INSERT INTO command into it, I'd be appreciative.

I've even tried this (pseudocode):

docmd.RUNSQL ( "INSERT INTO mylinked_table ( fields, morefields, etc) IN 'backend.mbd' VALUES ( 'blah', 'blah blah', 'etc')" )

Note the "IN 'backend.mdb'" part.

Even THAT works fine from Frontend.mbd 's VBA "immediate" window, but it won't work in a click event.

If anyone out there can preserve my sanity, I'd much appreciate it. Thanks!

-DW

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old August 30th, 2007, 10:15 AM
Friend of Wrox
Points: 9,516, Level: 42
Points: 9,516, Level: 42 Points: 9,516, Level: 42 Points: 9,516, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,060
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Yikes to linked tables.

I would use a provider statement and just bypass the backend and go right for the MySQL database, using ADO.

For example, I have a database front end with linked SQL Server tables for show, but all the Update and Instert events use the following sort of code:

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSQL As String
etc

sSQL = "INSERT INTO Table(Fields), Values(values)"

Set cn = New ADODB.Connection
cn.Open "Provider..."

Set rs = New ADODB.Recordset
rs.Open sSQL, cn, adOpenDynamic, adLockOptimistic

cn.Close

That does the trick for me.

Did that help at all? It doesn't resolve it the way you want it, but it works.

You can also set up a DSN and go right for that as well.



mmcdonal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old September 3rd, 2007, 08:30 PM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quick question:

for cn.open "provider..."

The program is stalling right there. I put a nice little collection of MsgBox items down the list to give me specific feedback of what's going on. (I.E. "SQL string built! Here it is: ......")

Well, it runs the one juuuuuust before this ("preparing to open provider"):

cn.Open "Driver={MySQL ODBC 3.51 Driver};Server=www.oursqldomain.net;Port=3306;Data base=data_base;User=data_user; Password=abc123;Option=3;"

And I never see the MsgBox "Provider opened" I stuck right after it. Soooo theres a problem with this, but I can't spot it. Any thoughts? Thanks!

-Duffy


Thanks!

-DW
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create record in linked SQL table Derek_05 Access VBA 3 June 1st, 2006 04:22 AM
Can a Make Table Query produce a Linked table? kronik Access 5 May 16th, 2006 07:17 AM
Access MDB with a Linked SQL Server Table..... timmaher Classic ASP Databases 0 September 28th, 2005 04:57 AM
linked table Tasha Access VBA 1 August 6th, 2004 04:04 PM
Access and update linked SQL Server 2000 table Lizu Access 9 May 10th, 2004 01:42 PM



All times are GMT -4. The time now is 01:20 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc