I have in excel file, which contains in button. So what Im trying to to do is, whenever I click the button. I wont to be able to send the time I click the button to a sql table. If someone can help. Please I need it.
I have in excel file, which contains in button. So what Im trying to to do is, whenever I click the button. I wont to be able to send the time I click the button to a sql table. If someone can help. Please I need it.
That means you need to have an ADO Connection Object and then execute a SQL Insert or Update statement on your database using said connection. There are many good tutorials and samples for how to work with data using ADO both of this site and throughout the net. A quick search would be in order.
Excel VBA question moved to Office Development
Please use [Code]your code goes in here[/Code] tags when posting code.
When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.
Creating A Wizard In VB.NET
Paging A Recordset
What is wrong with using On Error Resume Next
Good Article: Language Enhancements In Visual Basic 2010
Upgrading VB6 Code To VB.NET
Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked
I have in excel file, which contains in macro button. So what Im trying to to do is, whenever I click the button. I wont to be able to send the time I click the button to a sql table. If someone can help. If anyone know how to do this thru macro. Please point me in that direction.
what type of table?I wont to be able to send the time I click the button to a sql table.
what database?
what other code do you have for working with the database?
search in the database forum for insert or add to a recordset
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed![]()
pete
I tried in code on the marcos in excel, but it still not work propely. I wont the button to send a something to the table I have one sql. That something is like a example; whatever time i hit the marco button, I wont it to appear in the sql table when i click on the button. the code im working with is below, but dont know if im doing right or not.
Sub TestImportUsingADO()
Dim conString As String
conString = "Server=10.53.252.221;UID=phasqladmin;PWD=i82dothis;Database=phabsproduction;"
Dim query As String
query = "insert into [Table_1] ([Time Submited])values ('9-20-2012')"
Dim target As Range
Set target = ThisWorkbook.Sheets(2).Cells(3, 2)
target.CurrentRegion.Clear
Select Case ImportSQLtoRange(conString, query, target)
Case 1
MsgBox "Import database data error", vbCritical
Case Else
End Select
What is the code in the ImportSQLtoRange function?
I don't have that, having problems
the code you posted implies the existance of a function named ImportSQLtoRange() which accepts 3 parameters and returns a result that can be a 1
The code you have posted doesn't really do anything other than set some values for use in this function so ....