S
saraqpost
I'm trying to check to see if the user has already added a Truck/Date
combination (with Status = A), before the accmdSaveRecord.
I have been trying Dlookup and Dcount, in various combinations, to
accomplish this, but no luck. I can't get the complex statement to
work, and when I Dcount just the TrailerNum (text field) I get 0, but
there is a record on file.
Here's the situation and code:
Table: tblOutboundTrailer
Key: TrailerInfoKey
Fields (fieldname on frmNewTrailer): TrailerNum (me.txtTrailerNum)
Date (me.date)
Status (Defaults to "A". If a user requests 'delete a
trailer' I change the status to "D")
Code:
intcount = DCount("[TrailerInfoKey]", "tblOutboundTrailer", _
"[Date] = #" & Me.txtDate & "#") - WORKS! I get that the date is
on the table 13 times
intcount = DCount("[TrailerInfoKey]", "tblOutboundTrailer", _
"[Date] = #" & Me.txtDate & "#" & " AND [Status] = " & """ A & """)
- Compiles, but DOESN'T WORK - intcount is 0; there are 12 records with
the date and status = A
intcount = DCount("[TrailerInfoKey]", "tblOutboundTrailer", _
"[Date] = #" & Me.txtDate & "#" & " AND [Status] = " & """ A & """
_
& " AND [TrailerNum] = " & """ [strTrailerNum] & """) - Compiles,
but DOESN'T WORK - intcount is 0; there is 1 record with the date and
status = A and TrailerNum 1.
Any complex statements don't work. The simple one does. Can't figure
this out!
Thanks
Sara
combination (with Status = A), before the accmdSaveRecord.
I have been trying Dlookup and Dcount, in various combinations, to
accomplish this, but no luck. I can't get the complex statement to
work, and when I Dcount just the TrailerNum (text field) I get 0, but
there is a record on file.
Here's the situation and code:
Table: tblOutboundTrailer
Key: TrailerInfoKey
Fields (fieldname on frmNewTrailer): TrailerNum (me.txtTrailerNum)
Date (me.date)
Status (Defaults to "A". If a user requests 'delete a
trailer' I change the status to "D")
Code:
intcount = DCount("[TrailerInfoKey]", "tblOutboundTrailer", _
"[Date] = #" & Me.txtDate & "#") - WORKS! I get that the date is
on the table 13 times
intcount = DCount("[TrailerInfoKey]", "tblOutboundTrailer", _
"[Date] = #" & Me.txtDate & "#" & " AND [Status] = " & """ A & """)
- Compiles, but DOESN'T WORK - intcount is 0; there are 12 records with
the date and status = A
intcount = DCount("[TrailerInfoKey]", "tblOutboundTrailer", _
"[Date] = #" & Me.txtDate & "#" & " AND [Status] = " & """ A & """
_
& " AND [TrailerNum] = " & """ [strTrailerNum] & """) - Compiles,
but DOESN'T WORK - intcount is 0; there is 1 record with the date and
status = A and TrailerNum 1.
Any complex statements don't work. The simple one does. Can't figure
this out!
Thanks
Sara