Hi,
Thanks for your reply, I have amended the SQL and set the query running, however it has been running for over 5 minutes now and is still only 1 little blue bit of running through the query if you understand what i mean. This would suggest that the query is going to take a long time and i...
Hi,
Im fairly new to creating databases and please be nice as my database is probably not the best designed but im trying.
My database is designed to compare two datasets from our internal systems and then append data mimatches into [Mismatch Table - Results] then people can use forms and such...
Hello,
With the Workbook Open Event you could try this....
[code]
Private Sub Workbook_Open()
Sheets("Sheet1").Range("A:A").Calculate
End Sub
[\code]
Just change the sheet name and range to whatever you need...
no, as soon as it has put the SQL in is changes the statusbar to "connecting to datasource: for about 2 seconds and then ends....
The code takes less than 20 seconds to run...
Apologies...
Sub Refresh_Query_5A()
Dim SDate As Date
Dim EDate As Date
Dim MySQL As String
Sheets("Control").Select
SDate = Range("D19").Value
EDate = Range("D20").Value
SDate = CDate(SDate)
EDate = CDate(EDate)
SDate = Format(SDate, "mm-dd-yyyy")
EDate = Format(EDate, "mm-dd-yyyy")...
I have VBA cose that inserts SQL into microsoft query and then is supposed to refresh the query. The code runs fine without any errors and inserts the SQL into ms Query. once the code has finished if i look at the query it does not return any rows of data but then if i go into msQuery and exit...
i dont believe there is a way to stop this, excel has not been developed as a secure application, the security in excel is to avoid errors more than deny access. i am not aware of a way, but you could limit the access to certain usernames if that would help?
I have written two snippets of code one to convert the date to a string and another one to convert back to a date, im not sure if this is exactly what you want but:
Today = FormatDateTime(Now(), vbShortDate)
Tomorrow = FormatDateTime(Now() + 1, vbShortDate)
Today = CStr(Today)
Tomorrow =...
Also, once the code is in the open workbook module, yyou will need to tell VBA what it is refreshing ie:
Sheets("Sheet1").QueryTables(1).Refresh BackgroundQuery:=False
The problem im having seems odd, it connects to the database and then seems to refresh really quickly. when it finishes there is no data there, but if i go into microsoft wuery and click "cancel and return data to excel" then it runs the query with the parameters set by the VBA code. Does anyone...
ok sorry about this i have managed to get the dates in the right format now...
BUT!
the actual query is not refreshing, the SQL is being entered and if i go into microsoft query it has already been changed dependant on the variables and i can then run it but when it goes through the refresh...
Thanks for everyone's help...
There is just one last thing.... it is running fine now with no errors however it is running the query between the dates:
03-January-2008 & 04-January-2008 and what i need it to do is run from 01-March-2008 to 01-April 2008
i will post the code i have again so it...
Just A suggestion but would it work if you wrote:
Sub AddressFix()
Columns("N:N").Select
Selection.Replace What:=" Se ", Replacement:=" SE ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
This may not...
Thanks very much - That has helped, i was getting an object error, howver i have now changed the code to contain my variable and am now getting the error:
[Microsoft][ODBC SQL Server Driver][SQL Server]syntax error converting datetimefrom character string
the code I have chaged is:
MySQL =...
Hi,
I am trying to use SQL in VBA to query an external database, i have set the query up in microsoft query and just want to pass the SQL to the query with variables in each time. I am getting an error when running the code at With Sheets("Sheet1").Querytable(1)
The Code is as follows:
Sub...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.