469,275 Members | 1,749 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Help write a SQL in VBA

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
4 1550

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
Never mind, I got it :-)

Aug 16 '06 #3

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

Any ideas ?

Aug 16 '06 #4

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.

Similar topics

4 posts views Thread by PHPkemon | last post: by
5 posts views Thread by Tank | last post: by
1 post views Thread by rainbowii7 | last post: by
reply views Thread by Shaggyh | last post: by
5 posts views Thread by althafexcel | last post: by
9 posts views Thread by TF | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.