Criteria Help

Kango

Registered User.
Local time
Today, 14:37
Joined
Mar 11, 2004
Messages
29
Hi All ,

I have the following criteria

StrCriteria = "DepartureDate ='" & StrDtConv & "'" & " And " & "FlightNumber ='" & StrCriteriaMatch3 & " '"

It does not work because the DepartureDate Is a date field. I think I need to put some #’s around the StrDtConv, bit but I do not know where they go any bright ideas!!!!.


Thanks

Kango
 
If all you need is a # then try this...

StrCriteria = "DepartureDate ='#" & StrDtConv & "#'" & " And " & "FlightNumber ='" & StrCriteriaMatch3 & " '"
 
ghudson said:
If all you need is a # then try this...

StrCriteria = "DepartureDate ='#" & StrDtConv & "#'" & " And " & "FlightNumber ='" & StrCriteriaMatch3 & " '"
I don't think you need the ' in addition to the # delimiters. How about:
Code:
StrCriteria = "DepartureDate =#" & StrDtConv & "# And FlightNumber ='" & StrCriteriaMatch3 & " '"
That assumes also that FlightNumber is a string value.
 
dcx693 said:
I don't think you need the ' in addition to the # delimiters. How about:
Code:
StrCriteria = "DepartureDate =#" & StrDtConv & "# And FlightNumber ='" & StrCriteriaMatch3 & " '"
That assumes also that FlightNumber is a string value.

Hey!,

Thank you very much for doing that, I am just pasting the code in my procedure. It look's like it is going to work. I will post back if i have a problem. Thanks again much appreciated!!!


Kango
 
Sorry tried the fix but it does not work

Hi All,

I tried putting the Hashes in as suggested, but the criteria does not find the correct records that match. Any ideas on how to build a search criteria that searches for a date and string???

Thanks

Kango
 
There was a space at the end of the string:

strCriteria = "DepartureDate = #" & StrDtConv & "# And FlightNumber = """ & StrCriteriaMatch3 & """"
 
Still will not work!!!!!

Mile-O-Phile said:
There was a space at the end of the string:

strCriteria = "DepartureDate = #" & StrDtConv & "# And FlightNumber = """ & StrCriteriaMatch3 & """"


I think i better explain what i am trying to do may be you can just sort the problem - Here goes for the explanation -:




I have Db with two tables.

a) TblDailyFlightSchedule
b) TblDailyFlightPaxHistoryLog



The TblDailyFlightSchedule is created from a make table query and is updated on a daily basis. What I need to happen via a command button, is to update the TblDailyFlightPaxHistoryLog with the records from the TblDailyFlightSchedule. If the records already exist in the TblDailyFlightPaxHistoryLog then update with changes. If no records exist then add the new records to TblDailyFlightPaxHistoryLog. I have created the following code but it is not working as I expect?. The update and Addnew record criteria need to based on two fields (DepartureDate) , (FlightNumber) FlightNumber field is a string , and DepartureDate is date field.

Look Forward to your help!!!!


Public Sub ProcessDailyFltSchLog()
Dim ProcessDailyFltSchLogRst As DAO.Recordset
Dim ProcessDailyFltSchLogDbs As DAO.Database

Set ProcessDailyFltSchLogDbs = CurrentDb
Set ProcessDailyFltSchLogRst = CurrentDb.OpenRecordset("TblDailyFlightSchedule", dbOpenDynaset)

ProcessDailyFltSchLogRst.MoveFirst
Do Until ProcessDailyFltSchLogRst.EOF
With ProcessDailyFltSchLogRst

StrDtConv = Format(![DepartureDate], "DD MM YY")
StrCriteriaMatch2 = ![AirlineIataCode]
StrCriteriaMatch3 = ![FlightNumber]
StrCriteriaMatch4 = Nz(![IBFlightNumber], "")
StrCriteriaMatch5 = Nz(![DepartureTime], "0:00")
StrCriteriaMatch6 = Nz(![Destination], "NA")
UpdatePDFLx
.MoveNext
End With
Loop


Set ProcessDailyFltSchLogDbs = Nothing
Set ProcessDailyFltSchLogRst = Nothing
End Sub


Public Sub UpdatePDFLx()
Dim dbsUpdatePDFL As DAO.Database
Dim RstUpdatePDFL As DAO.Recordset
Dim StrCriteriax As String


Set dbsUpdatePDFL = CurrentDb
Set RstUpdatePDFL = CurrentDb.OpenRecordset("TblDailyFlightPaxHistoryLog", dbOpenDynaset)

StrDtConv = Format(StrDtConv, "DD MM YY")

StrCriteriax = "DepartureDate =#" & StrDtConv & "# And FlightNumber ='" & StrCriteriaMatch3 & " '"

With RstUpdatePDFL
.MoveFirst
.FindFirst StrCriteriax
Do Until .NoMatch
RstUpdatePDFL.Edit
![DepartureDate] = DtDeptDt
![AirlineIataCode] = StrCriteriaMatch2
![FlightNumber] = StrCriteriaMatch3
![IBFlightNumber] = StrCriteriaMatch4
![DepartureTime] = StrCriteriaMatch5
![Destination] = StrCriteriaMatch6

If RstUpdatePDFL.NoMatch Then
![DepartureDate] = DtDeptDt
![AirlineIataCode] = StrCriteriaMatch2
![FlightNumber] = StrCriteriaMatch3
![IBFlightNumber] = StrCriteriaMatch4
![DepartureTime] = StrCriteriaMatch5
![Destination] = StrCriteriaMatch6
End If
.Update
.FindNext StrCriteriax
Loop

End With
 
Have you tried using an update query instead?
 
ghudson said:
Have you tried using an update query instead?
No to be honest i have not. I was thinking about using a query, but the recordset being updated will get quite large overtime, and i was thinking that a query will become slower as the recordset grows. I would imagine the recordset to go over 200000 records. So my thoughts were to use DAO?. But if you think a query will perform ok then might be the way?.

Let me know.

Thanks
 
Kango said:
But if you think a query will perform ok then might be the way?
I have seen other posts stating that stored queries run faster than coded SQL and record sets. A few hundred thousand records is not a lot to update.
 

Users who are viewing this thread

Back
Top Bottom