I appreciate your persistence on this issue. I have gone back to
testing your suggestions.
My form code:
If Me.chkOldNetwork Then
Me.txtNetworks =
"""abc"",""cbs"",""nbc"",""fox"",""wb"",""upn"""
Else
Me.txtNetworks = """abc"",""cbs"",""nbc"",""fox"",""cw"""
End If
The immediate window evaluates my query criteria as the following:
?"IN (" & [Forms]![frmWeeklyBroadcastSchedule]![txtNetworks] & ")"
IN ("abc","cbs","nbc","fox","cw")
This all looks good but still when the query runs, I get no records
from this condition.
I understand what you are saying about the single quote example and
that it should work. This example should also work. I have tested this
before and I still get no records. If I evaluate the criteria
expressions in the Immediate window, they look fine. I can then copy
those text values into the criteria as another test and that works
fine. Only when I run the form to call the query and build everything
dynamically does it return no records. Uggh.
I have tried adding quotes and # symbols around my criteria date
expressions, although they worked before without this. I have converted
my values in the text boxes to dates using CDate as an additional
check, although that also worked before without this step. Nothing
helps resolve the error "3464 data type mismatch in criteria
expression" I get.
The SQL string is quite long and hard to read but here it is. This
first SQL example is my original query that has always worked. This is
with the network names coded directly into the query and no dynamic
changes being made by the form.
SELECT tblEpisodeAirdates.EpisodeAirdate,
Format([episodeairdate],"dddd") AS DayName,
Format([episodeairdate],"ddd") AS AbbrDayName,
MonthName(DatePart("m",[EpisodeAirdate])) AS [Month],
DatePart("d",[EpisodeAirdate]) AS [Day],
Right(Year([EpisodeAirdate]),4) AS [Year], tblNetworks.NetworkAbbr,
CDate(IIf(IsNull([SpecialAirtimeBegin]),tblStandardAirtimes!StandardAirtimeBegin,tblEpisodeAirdates!SpecialAirtimeBegin))
AS StartTime,
CDate(IIf(IsNull([SpecialAirtimeEnd]),tblStandardAirtimes!StandardAirtimeEnd,tblEpisodeAirdates!SpecialAirtimeend))
AS EndTime, tblPrograms.ProgramName, tblEpisodes.EpisodeName,
tblPrograms.WBShow, tblEpisodeAirdates.Confirmed,
tblEpisodeAirdates.Repeat, tblEpisodeAirdates.Special,
tblEpisodeAirdates.RepeatSpecial, tblEpisodeAirdates.SeasonPremiere,
tblEpisodeAirdates.TPPremiere, tblEpisodeAirdates.Debut,
tblEpisodeAirdates.DebutPreview, tblEpisodeAirdates.SeasonFinale,
tblEpisodeAirdates.SeriesFinale, IIf([repeat]=False,Null,"(R)") AS
strRepeat, IIf([special]=False,Null,"(S)") AS strSpecial,
IIf([repeatspecial]=False,Null,"(RS)") AS strRepeatSpecial,
IIf([SeasonPremiere]=False,Null,"(Season Premiere) ") AS
strSeasonPremiere, IIf([TPPremiere]=False,Null,"(T.P. Premiere) ") AS
strTPPremiere, IIf([Debut]=False,Null,"(Debut) ") AS strDebut,
IIf([DebutPreview]=False,Null,"(Debut/Preview) ") AS strDebutPreview,
IIf([SeasonFinale]=False,Null,"(Season Finale)") AS strSeasonFinale,
IIf([SeriesFinale]=False,Null,"(Series Finale) ") AS strSeriesFinale,
IIf(IsNull(tblEpisodes!GuestStarNames),Null,"Guest:" & [GuestStarNames]
& " ") AS strGuestStars, tblEpisodeAirdates.EpisodeAirdateNotes,
IIf([EpisodeName]="Unknown",Null,[EpisodeName] & " ") AS strEpisode,
UCase([ProgramName]) & " " & [strRepeat] & [strSpecial] &
[strRepeatSpecial] AS ProgramLine, [strEpisode] & [strSeasonPremiere] &
[strTPPremiere] & [strDebut] & [strDebutPreview] & [strSeasonFinale] &
[strSeriesFinale] & [strGuestStars] & [EpisodeAirdateNotes] AS
EpisodeLine, IIf((tlkpGenres!GenreNameID=8) Or
(tlkpGenres!GenreNameID=9),"Movie:" & tblEpisodes!EpisodeName & " (" &
[NetworkAbbr] & ")",[ProgramName] & " " & [strSeasonPremiere] &
[strTPPremiere] & [strDebut] & [strDebutPreview] & [strSeasonFinale] &
[strSeriesFinale] & "(" & [NetworkAbbr] & ")") AS HighlightLine,
tblEpisodeAirdates.CableHighlight, tlkpGenreNames.GenreNameID,
tlkpGenreNames.GenreName, tblEpisodeAirdates.BacktoBack,
tblBacktoBack.BacktoBackEndTime, tblEpisodeAirdates.PrintSpecialAirtime
INTO tblExport
FROM (tlkpGenreNames INNER JOIN tlkpGenres ON
tlkpGenreNames.GenreNameID = tlkpGenres.GenreNameID) INNER JOIN
(tblPrograms INNER JOIN ((tblProgramSeasons INNER JOIN (tblEpisodes
INNER JOIN (tblEpisodeAirdates LEFT JOIN tblBacktoBack ON
tblEpisodeAirdates.EpisodeAirdateID = tblBacktoBack.EpisodeAirdateID)
ON tblEpisodes.EpisodeID = tblEpisodeAirdates.EpisodeID) ON
tblProgramSeasons.ProgramSeasonID = tblEpisodes.ProgramSeasonID) INNER
JOIN (tblNetworks INNER JOIN (tblNetworkPrograms INNER JOIN
tblStandardAirtimes ON tblNetworkPrograms.NetworkProgramID =
tblStandardAirtimes.NetworkProgramID) ON tblNetworks.NetworkID =
tblNetworkPrograms.NetworkID) ON (tblStandardAirtimes.StandardAirtimeID
= tblEpisodeAirdates.StandardAirtimeID) AND
(tblProgramSeasons.ProgramSeasonID =
tblNetworkPrograms.ProgramSeasonID)) ON tblPrograms.ProgramID =
tblProgramSeasons.ProgramID) ON tlkpGenres.GenreID =
tblPrograms.GenreID
WHERE (((tblEpisodeAirdates.EpisodeAirdate) Between
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekBegin] And
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekEnd]) AND
((tblNetworks.NetworkAbbr)="abc" Or (tblNetworks.NetworkAbbr)="cbs" Or
(tblNetworks.NetworkAbbr)="nbc" Or (tblNetworks.NetworkAbbr)="fox" Or
(tblNetworks.NetworkAbbr)="wb" Or (tblNetworks.NetworkAbbr)="upn") AND
((tblNetworks.BroadcastNetwork)=Yes) AND
((tblNetworkPrograms.Cancelled)=No)) OR
(((tblEpisodeAirdates.EpisodeAirdate) Between
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekBegin] And
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekEnd]) AND
((tblEpisodeAirdates.CableHighlight)=Yes) AND
((tblNetworks.BroadcastNetwork)=No) AND
((tblNetworkPrograms.Cancelled)=No)) OR
(((tblEpisodeAirdates.EpisodeAirdate) Between
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekBegin] And
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekEnd] And
(tblEpisodeAirdates.EpisodeAirdate)<=[lastAirdate]) AND
((tblNetworks.NetworkAbbr)="abc" Or (tblNetworks.NetworkAbbr)="cbs" Or
(tblNetworks.NetworkAbbr)="nbc" Or (tblNetworks.NetworkAbbr)="fox" Or
(tblNetworks.NetworkAbbr)="wb" Or (tblNetworks.NetworkAbbr)="upn") AND
((tblNetworks.BroadcastNetwork)=Yes) AND
((tblNetworkPrograms.Cancelled)=Yes)) OR
(((tblEpisodeAirdates.EpisodeAirdate) Between
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekBegin] And
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekEnd] And
(tblEpisodeAirdates.EpisodeAirdate)<=[lastAirdate]) AND
((tblEpisodeAirdates.CableHighlight)=Yes) AND
((tblNetworks.BroadcastNetwork)=No) AND
((tblNetworkPrograms.Cancelled)=Yes))
ORDER BY tblEpisodeAirdates.EpisodeAirdate, tblNetworks.NetworkAbbr,
CDate(IIf(IsNull([SpecialAirtimeBegin]),tblStandardAirtimes!StandardAirtimeBegin,tblEpisodeAirdates!SpecialAirtimeBegin));
===============
Here is the current example where I have even added the quotes and #
signs around the Between phrase and I still get the 3464 error. I have
also tried using OR instead of IN and using the NetworkID's instead of
their Abbreviation Names. I have the same problem no matter which
example I try. I am so frustrated with this.
SELECT tblEpisodeAirdates.EpisodeAirdate,
Format([episodeairdate],"dddd") AS DayName,
Format([episodeairdate],"ddd") AS AbbrDayName,
MonthName(DatePart("m",[EpisodeAirdate])) AS [Month],
DatePart("d",[EpisodeAirdate]) AS [Day],
Right(Year([EpisodeAirdate]),4) AS [Year], tblNetworks.NetworkAbbr,
CDate(IIf(IsNull([SpecialAirtimeBegin]),tblStandardAirtimes!StandardAirtimeBegin,tblEpisodeAirdates!SpecialAirtimeBegin))
AS StartTime,
CDate(IIf(IsNull([SpecialAirtimeEnd]),tblStandardAirtimes!StandardAirtimeEnd,tblEpisodeAirdates!SpecialAirtimeend))
AS EndTime, tblPrograms.ProgramName, tblEpisodes.EpisodeName,
tblPrograms.WBShow, tblEpisodeAirdates.Confirmed,
tblEpisodeAirdates.Repeat, tblEpisodeAirdates.Special,
tblEpisodeAirdates.RepeatSpecial, tblEpisodeAirdates.SeasonPremiere,
tblEpisodeAirdates.TPPremiere, tblEpisodeAirdates.Debut,
tblEpisodeAirdates.DebutPreview, tblEpisodeAirdates.SeasonFinale,
tblEpisodeAirdates.SeriesFinale, IIf([repeat]=False,Null,"(R)") AS
strRepeat, IIf([special]=False,Null,"(S)") AS strSpecial,
IIf([repeatspecial]=False,Null,"(RS)") AS strRepeatSpecial,
IIf([SeasonPremiere]=False,Null,"(Season Premiere) ") AS
strSeasonPremiere, IIf([TPPremiere]=False,Null,"(T.P. Premiere) ") AS
strTPPremiere, IIf([Debut]=False,Null,"(Debut) ") AS strDebut,
IIf([DebutPreview]=False,Null,"(Debut/Preview) ") AS strDebutPreview,
IIf([SeasonFinale]=False,Null,"(Season Finale)") AS strSeasonFinale,
IIf([SeriesFinale]=False,Null,"(Series Finale) ") AS strSeriesFinale,
IIf(IsNull(tblEpisodes!GuestStarNames),Null,"Guest:" & [GuestStarNames]
& " ") AS strGuestStars, tblEpisodeAirdates.EpisodeAirdateNotes,
IIf([EpisodeName]="Unknown",Null,[EpisodeName] & " ") AS strEpisode,
UCase([ProgramName]) & " " & [strRepeat] & [strSpecial] &
[strRepeatSpecial] AS ProgramLine, [strEpisode] & [strSeasonPremiere] &
[strTPPremiere] & [strDebut] & [strDebutPreview] & [strSeasonFinale] &
[strSeriesFinale] & [strGuestStars] & [EpisodeAirdateNotes] AS
EpisodeLine, IIf((tlkpGenres!GenreNameID=8) Or
(tlkpGenres!GenreNameID=9),"Movie:" & tblEpisodes!EpisodeName & " (" &
[NetworkAbbr] & ")",[ProgramName] & " " & [strSeasonPremiere] &
[strTPPremiere] & [strDebut] & [strDebutPreview] & [strSeasonFinale] &
[strSeriesFinale] & "(" & [NetworkAbbr] & ")") AS HighlightLine,
tblEpisodeAirdates.CableHighlight, tlkpGenreNames.GenreNameID,
tlkpGenreNames.GenreName, tblEpisodeAirdates.BacktoBack,
tblBacktoBack.BacktoBackEndTime, tblEpisodeAirdates.PrintSpecialAirtime
INTO tblExport
FROM (tlkpGenreNames INNER JOIN tlkpGenres ON
tlkpGenreNames.GenreNameID = tlkpGenres.GenreNameID) INNER JOIN
(tblPrograms INNER JOIN ((tblProgramSeasons INNER JOIN (tblEpisodes
INNER JOIN (tblEpisodeAirdates LEFT JOIN tblBacktoBack ON
tblEpisodeAirdates.EpisodeAirdateID = tblBacktoBack.EpisodeAirdateID)
ON tblEpisodes.EpisodeID = tblEpisodeAirdates.EpisodeID) ON
tblProgramSeasons.ProgramSeasonID = tblEpisodes.ProgramSeasonID) INNER
JOIN (tblNetworks INNER JOIN (tblNetworkPrograms INNER JOIN
tblStandardAirtimes ON tblNetworkPrograms.NetworkProgramID =
tblStandardAirtimes.NetworkProgramID) ON tblNetworks.NetworkID =
tblNetworkPrograms.NetworkID) ON (tblStandardAirtimes.StandardAirtimeID
= tblEpisodeAirdates.StandardAirtimeID) AND
(tblProgramSeasons.ProgramSeasonID =
tblNetworkPrograms.ProgramSeasonID)) ON tblPrograms.ProgramID =
tblProgramSeasons.ProgramID) ON tlkpGenres.GenreID =
tblPrograms.GenreID
WHERE (((tblEpisodeAirdates.EpisodeAirdate)="Between #" &
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekBegin] & "# And #" &
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekEnd] & "#") AND
((tblNetworks.NetworkAbbr)="IN (" &
[Forms]![frmWeeklyBroadcastSchedule]![txtNetworks] & ")") AND
((tblNetworks.BroadcastNetwork)=Yes) AND
((tblNetworkPrograms.Cancelled)=No)) OR
(((tblEpisodeAirdates.EpisodeAirdate)="Between #" &
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekBegin] & "# And #" &
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekEnd] & "#") AND
((tblEpisodeAirdates.CableHighlight)=Yes) AND
((tblNetworks.BroadcastNetwork)=No) AND
((tblNetworkPrograms.Cancelled)=No)) OR
(((tblEpisodeAirdates.EpisodeAirdate)="Between #" &
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekBegin] & "# And #" &
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekEnd] & "# And <=#" &
[lastAirdate] & "#") AND ((tblNetworks.NetworkAbbr)="IN (" &
[Forms]![frmWeeklyBroadcastSchedule]![txtNetworks] & ")") AND
((tblNetworks.BroadcastNetwork)=Yes) AND
((tblNetworkPrograms.Cancelled)=Yes)) OR
(((tblEpisodeAirdates.EpisodeAirdate)="Between #" &
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekBegin] & "# And #" &
[Forms]![frmWeeklyBroadcastSchedule]![txtWeekEnd] & "# And <=#" &
[lastAirdate] & "#") AND ((tblEpisodeAirdates.CableHighlight)=Yes) AND
((tblNetworks.BroadcastNetwork)=No) AND
((tblNetworkPrograms.Cancelled)=Yes))
ORDER BY tblEpisodeAirdates.EpisodeAirdate, tblNetworks.NetworkAbbr,
CDate(IIf(IsNull([SpecialAirtimeBegin]),tblStandardAirtimes!StandardAirtimeBegin,tblEpisodeAirdates!SpecialAirtimeBegin));