waxdart23
Registered User.
- Local time
- Today, 14:01
- Joined
- Nov 20, 2002
- Messages
- 25
I have a form which has "Start_Date", "End_Date" and "TableName" text fields and I am trying to create a new table using these parameters.
I have a command button with the following code -
Dim strSQL As String
strSQL = "SELECT StewardDetails.First_Name, StewardDetails.Last_Name, Performances.Performance, "
strSQL = strSQL & "Performances.Perf_Date, Performances.Duration INTO "
strSQL = strSQL & "INTO " & Chr(34) & TableName & Chr(34) & " "
strSQL = strSQL & "FROM StewardDetails INNER JOIN (Performances INNER JOIN StewardAvailability "
strSQL = strSQL & "ON Performances.ID = StewardAvailability.Perf_ID) ON StewardDetails.ID "
strSQL = strSQL & "= StewardAvailability.Stewards_ID WHERE (((Performances.Perf_Date) Between "
strSQL = strSQL & "[Forms]![frmTestCreateHours]![StartDate] And [Forms]![frmTestCreateHours]![EndDate]) "
strSQL = strSQL & "AND ((StewardAvailability.Availability)=True)) ORDER BY StewardDetails.Last_Name, "
strSQL = strSQL & "Performances.Perf_Date;"
DoCmd.RunSQL strSQL
When I try to run it I get a Run-Time error (see attached jpg) and it highights the DoCmd.RunSQL strSQL part of the code.
I have also tried running it in a seperate module passing the table name, but it was unable to find the subroutine when I ran it.
Any ideas?
I have a command button with the following code -
Dim strSQL As String
strSQL = "SELECT StewardDetails.First_Name, StewardDetails.Last_Name, Performances.Performance, "
strSQL = strSQL & "Performances.Perf_Date, Performances.Duration INTO "
strSQL = strSQL & "INTO " & Chr(34) & TableName & Chr(34) & " "
strSQL = strSQL & "FROM StewardDetails INNER JOIN (Performances INNER JOIN StewardAvailability "
strSQL = strSQL & "ON Performances.ID = StewardAvailability.Perf_ID) ON StewardDetails.ID "
strSQL = strSQL & "= StewardAvailability.Stewards_ID WHERE (((Performances.Perf_Date) Between "
strSQL = strSQL & "[Forms]![frmTestCreateHours]![StartDate] And [Forms]![frmTestCreateHours]![EndDate]) "
strSQL = strSQL & "AND ((StewardAvailability.Availability)=True)) ORDER BY StewardDetails.Last_Name, "
strSQL = strSQL & "Performances.Perf_Date;"
DoCmd.RunSQL strSQL
When I try to run it I get a Run-Time error (see attached jpg) and it highights the DoCmd.RunSQL strSQL part of the code.
I have also tried running it in a seperate module passing the table name, but it was unable to find the subroutine when I ran it.
Any ideas?