WalterHeisenberg
Technical User
- Mar 28, 2008
- 159
Hello,
First I am a beginner to VBA. I was asked to create an Excel workbook that when opened prompted the user for a date and executed a SQL query using that date as part of the where clause.
My first though was to create a macro to figure out how to get the SQL query linked up to a buttonclick sub. No problem there.
I have two issues, one, I can't get the form to load on startup! I tried adding sheet activate for userform.show() but that didn't do it. I didn't see anything on form properties. This must be simple.
Issue 2, I tried using the following syntax on the query:
I am getting a SQL syntax error. Thanks so much for help in advance! I appreciate it.
First I am a beginner to VBA. I was asked to create an Excel workbook that when opened prompted the user for a date and executed a SQL query using that date as part of the where clause.
My first though was to create a macro to figure out how to get the SQL query linked up to a buttonclick sub. No problem there.
I have two issues, one, I can't get the form to load on startup! I tried adding sheet activate for userform.show() but that didn't do it. I didn't see anything on form properties. This must be simple.
Issue 2, I tried using the following syntax on the query:
Code:
Destination:=Range("$A$1")).QueryTable.CommandText = Array("SELECT * FROM ""SAMINC"".""dbo"".""PAYMENTS" WHERE DATE = " & TEXTBOX1.TEXT & "")
I am getting a SQL syntax error. Thanks so much for help in advance! I appreciate it.