By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,872 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,872 IT Pros & Developers. It's quick & easy.

Help write a SQL in VBA

P: n/a
Hello all

How do I write this SQL in VBA code:
SELECT DISTINCTROW Employees.UsernameHold, [Expense
Reports].ExpenseReportID, [Expense Reports].EmployeeID, [Expense
Reports].ExpenseType, [Expense Reports].ExpenseRptName, [Expense
Reports].ExpenseRptDescr, [Expense Reports].DateSubmitted, [Expense
Reports].DepartmentCharged, [Expense Reports].BusinessPurpose, [Expense
Reports].[Period Ending], [Expense Reports].[End Milage], [Expense
Reports].[Start Milage], [Expense Reports].[Bus Miles] FROM Employees
INNER JOIN [Expense Reports] ON Employees.EmployeeID=[Expense
Reports].EmployeeID WHERE (((Employees.UsernameHold)=CurrentUser()) AND
(([Expense Reports].EmployeeID)=[forms]![Expense Reports by
Employee]![EmployeeID]));

Like I know how to write:
SELECT Employees.EmployeeID, Employees.DepartmentName,
Employees.EmployeeNumber, Employees.FirstName, Employees.LastName,
Employees.Notes, Employees.[Auto Year], Employees.[Auto Condition],
Employees.[Auto Make], Employees.UsernameHold FROM Employees

-----Me.RecordSource = "SELECT * FROM Employees"
But I dont know how to write the other SQL, Can somebody tell me please

Thank you in advance

Aug 16 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

SELECT [Expense Reports].ExpenseReportID, [Expense Reports].EmployeeID,
[Expense Reports].ExpenseType, [Expense Reports].ExpenseRptName,
[Expense Reports].ExpenseRptDescr, [Expense Reports].DateSubmitted,
[Expense Reports].DepartmentCharged, [Expense Reports].BusinessPurpose,
[Expense Reports].[Period Ending], [Expense Reports].[End Milage],
[Expense Reports].[Start Milage], [Expense Reports].[Bus Miles],
[Expense Reports].UsernameHold
FROM [Expense Reports]
WHERE ((([Expense Reports].EmployeeID)=[forms]![Expense Reports by
Employee]![EmployeeID]));

This is the SQL that I need to write in VBA not the last I posted

Aug 16 '06 #2

P: n/a
Never mind, I got it :-)

Aug 16 '06 #3

P: n/a

Ups, no!....still need help, sorry about that

Any ideas ?

Aug 16 '06 #4

P: n/a

Me.RecordSource = "SELECT [Expense Reports].ExpenseReportID, [Expense
Reports].EmployeeID, " & _
"[Expense Reports].ExpenseType, [Expense Reports].ExpenseRptName, " & _
"[Expense Reports].ExpenseRptDescr, [Expense Reports].DateSubmitted, " & _
"[Expense Reports].DepartmentCharged, [Expense Reports].BusinessPurpose, " &
_
"[Expense Reports].[Period Ending], [Expense Reports].[End Milage], " & _
"[Expense Reports].[Start Milage], [Expense Reports].[Bus Miles], " & _
"[Expense Reports].UsernameHold " & _
"FROM [Expense Reports] " & _
"WHERE ((([Expense Reports].EmployeeID)=[forms]![Expense Reports by
Employee]![EmployeeID]));"

Aug 16 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.