olspookishmagus
New member
- Local time
- Today, 22:22
- Joined
- Oct 3, 2005
- Messages
- 8
Hello once more, I could use your help and thanks in advance for it.
There's a table named Customers that has as a primary key, an autonumbering field named Customer_ID, a text filed named Surname and a text field named Name.
Whenever you wish to see a customer's history (like completed or pending orders) I wanted to make the form History that appears to display on it's caption. History: along with the customer's surname followed by his name.
Keep in mind that whenever you try to call the History form, you call it from withing the Customers form that displays the customer's details and therefore you can pass the Customer_ID to the new form.
My objective is to be able retrieve stings throught SQL queries from within the VBA without the need of using additional macros or queries. Keep in mind that this is about Microsoft Office 2000 SP-3 and Microsoft Visual Basic 6.0.
And here's what I've done so far for this.
In the History form, I have created two string variables named Surname_Name and SQL_String within the Form_Load event like this:
Then, I assing the SQL_String variable the following value, like this:
And then I try to assing the output of a desired SQL query to Surname_Name and finally get it to be displayed to the form's caption, like this:
But whenever this happens I get an error dialog box that reads:
There's a table named Customers that has as a primary key, an autonumbering field named Customer_ID, a text filed named Surname and a text field named Name.
Whenever you wish to see a customer's history (like completed or pending orders) I wanted to make the form History that appears to display on it's caption. History: along with the customer's surname followed by his name.
Keep in mind that whenever you try to call the History form, you call it from withing the Customers form that displays the customer's details and therefore you can pass the Customer_ID to the new form.
My objective is to be able retrieve stings throught SQL queries from within the VBA without the need of using additional macros or queries. Keep in mind that this is about Microsoft Office 2000 SP-3 and Microsoft Visual Basic 6.0.
And here's what I've done so far for this.
In the History form, I have created two string variables named Surname_Name and SQL_String within the Form_Load event like this:
Code:
Private Sub Form_Load
Dim Surname_Name As String
Dim SQL_String As String
...
Code:
SQL_String = "SELECT [Customers]![Surname]+' '+[Customers]![Name] As Surname_Name FROM Customers WHERE (((Customers.Customer_ID)=1));)"
And then I try to assing the output of a desired SQL query to Surname_Name and finally get it to be displayed to the form's caption, like this:
Code:
Surname_Name = DoCmd.RunSQL(SQL_String)
Me.Form.Caption = "History of customer: " & Surname_Name
But whenever this happens I get an error dialog box that reads:
and then the RunSQL command gets highlighted and the execution breaks.Compile Error:
Expected function or variable