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.
Printable View
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
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?Quote:
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 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 ....