Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Parameters in a SQL 7.0 Query

Status
Not open for further replies.

BlackKnight

Programmer
Oct 18, 2000
348
US
Hi folks,
I am converting Access queries to SQL 7.0 statements.

In an Access select query I have a reference to a control on a form. How do I convert the query to a SQL 7.0 statement? Here is the query: Thanx in advance.

SELECT DISTINCTROW tblCustomerContactDepartment.strDepartmentName, tblCustomer.strCompanyName, tblCustomerContactDepartment.strContactID
FROM tblCustomer INNER JOIN tblCustomerContactDepartment ON tblCustomer.strCustomerID = tblCustomerContactDepartment.strContactID IN 'customer.mdb'
WHERE (((tblCustomerContactDepartment.strContactID)=[Forms]![frmCustomerContact].[zstxtCustomerID]))
ORDER BY tblCustomerContactDepartment.strDepartmentName
WITH OWNERACCESS OPTION;

Have a good one!
Keith
 
If you are just making a query then I would Link the SQL tables and use the query as is. But if you need to edit the SQL data, I have had better luck writing VBA code using ADO.
here is an Access 2000 example:
----------------------------
Dim Conn As ADODB.Connection
Dim rst As ADODB.Recordset

Set Conn = New ADODB.Connection
Set rst = New ADODB.Recordset

Conn.Open "driver=SQL Server;server=smallbserver;uid=sa;pwd=;database=Universal;"
Dim SQL As String
SQL = "Select Max(PURCH_ORDER) AS LastPO From PO"
rst.Open SQL, Conn, adOpenStatic, adLockOptimistic

' Add data to fields
Me!PURCH_ORDER = Val(rst!LastPO) + 1
Me!ORDER_ENTRY_DATE = Format(Now, "mm/dd/yy")
-------------------------------

Then in the VBA program click the "Tools" menu "References"
put a Check in "Microsoft Visual Basic for Applications Extensibility 5.3"

Otherwise I got Errors and could not save records to the database.



DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top