Advertisement
Richbadniss

access_test

Nov 22nd, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. Public Sub CreateQueries()
  2. Dim db As Database
  3. Set db = CurrentDb
  4.  
  5. On Error Resume Next
  6.  
  7. ' Create qry_Company
  8. db.Execute "CREATE VIEW qry_Company AS " & _
  9. "SELECT Company_Name, Address FROM COMPANY;"
  10.  
  11. ' Create qry_total_guest
  12. db.Execute "CREATE VIEW qry_total_guest AS " & _
  13. "SELECT COUNT(*) AS TotalGuests FROM GUEST;"
  14.  
  15. ' Create qry_EarlyPlatinum
  16. db.Execute "CREATE VIEW qry_EarlyPlatinum AS " & _
  17. "SELECT c.Company_Name, " & _
  18. "g.First_Name & ' ' & g.Last_Name AS Guest_Name, " & _
  19. "g.Package_ID, p.Early_Bird, p.Final_Cost " & _
  20. "FROM (COMPANY c INNER JOIN GUEST g ON c.Company_ID = g.Company_ID) " & _
  21. "INNER JOIN PAYMENT p ON g.Guest_ID = p.Guest_ID " & _
  22. "WHERE p.Early_Bird = True AND g.Package_ID LIKE 'PTM*';"
  23.  
  24. ' Create qry_international
  25. db.Execute "CREATE VIEW qry_international AS " & _
  26. "SELECT g.First_Name & ' ' & g.Last_Name AS Guest_Name, " & _
  27. "g.Package_ID, p.Early_Bird AS Status, " & _
  28. "g.Date_Of_Reservation, p.Final_Cost " & _
  29. "FROM GUEST g INNER JOIN PAYMENT p ON g.Guest_ID = p.Guest_ID " & _
  30. "WHERE g.Telephone LIKE '(+*';"
  31.  
  32. Set db = Nothing
  33. MsgBox "Queries created successfully!", vbInformation
  34. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement