Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Make-table query and VB Help?

Author  Topic 

phattymcbiff
Starting Member

1 Post

Posted - 2007-08-01 : 12:36:59
Hello, and thanks for reading!

I am stuck it appears, I need to use VB and SQL commands to run a command in Access. What I am wanting to do is Open a Make-Table query that will exist from an excel sheet. I would also like to find a way to refresh that excel sheet with VB. Behind this command button will be some SQL coding that says compare this table to that sheet whatever matches please invalidate.
I will post the code I have so far and let me know what you think.
Sorry if this isnt worded properly my brain just isnt functioning today I think is the biggest problem.
I am sure this is easy to someone, however I have been googling and reading and for someone reason it doesnt click.

Private Sub btnInvalidate_Click()
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim sql As String

DoCmd.OpenQuery (Permits_needing_invalidatedQRY)

conn.Open "DSN=PermitInvalidator"


sql = "UPDATE table_acs_credential RIGHT JOIN Converted_Numbers ON table_acs_credential.Credential_ID = Converted_Numbers.Permits_needing_Deleted SET table_acs_credential.Cred_Validity = INVL"

cmd.ActiveConnection = conn
cmd.CommandText = sql
cmd.Execute

conn.Close

End Sub

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2007-08-03 : 15:10:58
I'm sorry. What exactly was your question?

And you'll probably have better luck posting it to the Other Development Tools forum, since your question is about VBA and not SQL Server.
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2007-08-04 : 06:46:48
the sql statement is jumbled up if it's supposed to be mssql

update tablename1
set fieldname=t2.fieldname
from tablename1 t1
right join tablename1 t2 on t1.column1=t2.column2
where....

otherwise it's an MSAccess question and there's a forum on that as far as I can remember on this site as well

HTH

--------------------
keeping it simple...
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-08-04 : 08:42:20
(moved to MS Access forum ...)

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -