D
Dale Fye
Guys,
Thanks for this discussion. I has been very enlightening. I'll do some
tests on my own as time permits.
Dale
Thanks for this discussion. I has been very enlightening. I'll do some
tests on my own as time permits.
Dale
Did you test using perfmon.exe to watch the network traffic?
--
Arvin Meyer, MCP, MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com
Arvin said:Arvin,
Any particular reason that you are opening a recordset rather than
just using DCOUNT?
Yes, the Domain functions are much slower than pulling recordsets
because they don't take advantage of indexes. [snip]Cite? Testing on a large sample table before and after adding an index
clearly shows that domain functions do use the index.
- Show quoted text -
Opal,
Post your code (copy and paste) so we can see exactly what you are working
with.
Dale
- Show quoted text -
This was Arvin's recommendation as I interpreted it...
Private Sub Form_Load()
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Select * From NorthWeldDailyTable Where
txtDate = Date();")
If Not rst.EOF Then rst.MoveLast
If rst.RecordCount > 0 Then
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate = " & Date
Else
DoCmd.OpenForm "NorthWeldDailyfrm", , , , acFormAdd
End If
Exit_Here:
DoCmd.SetWarnings True
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub
Error_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here
End Sub- Hide quoted text -
- Show quoted text -
Arvin & Rick,
I'm sorry, but:
" Did you test using perfmon.exe to watch the network traffic?"
is something I do not understand and do not see how this helps me with
my problem?
Am I experimenting with quotes and hash marks even though my form is
bound.....?
Should I make my form unbound and try??? Help!!! Please?
[ . . . ]Opal said:This was Arvin's recommendation as I interpreted it...
Private Sub Form_Load()
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Select * From NorthWeldDailyTable Where
txtDate = Date();")
If Not rst.EOF Then rst.MoveLast
If rst.RecordCount > 0 Then
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate = " & Date
Else
DoCmd.OpenForm "NorthWeldDailyfrm", , , , acFormAdd
End If
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate=Date()"0 Then
An article in Access Advisor magazine (years ago) discussed
testing and comparison of all of the lookup methods and DLookup()
(when used with an index) came in second place losing out only to
Seek. It found only a negligible difference between DLookup() and
a Recordset with the Recordset actually being the slower of the
two.
Private Sub Form_Load()
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Select * From NorthWeldDailyTable
Where txtDate = Date();")
If Not rst.EOF Then rst.MoveLast
If rst.RecordCount > 0 Then
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate = " &
Date
Else
DoCmd.OpenForm "NorthWeldDailyfrm", , , , acFormAdd
End If
Exit_Here:
DoCmd.SetWarnings True
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub
Error_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here
End Sub
David W. Fenton said:An article in Access Advisor magazine (years ago) discussed
testing and comparison of all of the lookup methods and DLookup()
(when used with an index) came in second place losing out only to
Seek. It found only a negligible difference between DLookup() and
a Recordset with the Recordset actually being the slower of the
two.
Until Access 2000, I belive, all the domain aggregate functions were
slow on linked tables. That was why Trevor Best wrote his wonderful
t-functions to replace the built-in domain aggregate functions
(tCount(), tLookup(), etc.). After Access fixed the problem with
linked tables being slow (it may have been a service pack of A97
that fixed it, now that I think back on it), there was no longer any
need for it, but I'd become addicted to my own alterations of
Trevor's functions (where I used an optional argument supplying a
database variable so I could run them on something other than
CurrentDB()).
Seek, of course, is useless for lookups on more than one table.
And I just don't see it as useful in much of any circumstances.
Recordset.FindFirst can be optimized if your recordset is ordered by
the field being searched on. I did a whole bunch of testing on this
a couple of years ago and found that FindFirst is faster with an
index, but seems to do something of a table scan, as the time to
find a value is linearly proportional to the distance from the top
of the table. Because of that, you can optimize the FindFirst by
checking where you are in the recordset and doing a FindPrevious or
FindNext based on whether the next-sought value is greater than or
less than the current value.
To illustrate, say you have a table with FK DonorID, and you open a
recordset on that table, with a primary sort by DonorID and a
secondary sort by some other value. If you FindFirst
"[DonorID]=500000" you'd start from the top. For you next FindFirst,
if you're looking for 100000, then do a FindPrevious, and if you're
looking for 800000 do a FindNext. This improved performance by a
noticeable amount.
My recent work has reminded me of that testing, because I'm upsizing
the app that I did that testing for, and a stored procedure makes it
possible for me to abandon the persistent recordset that I was using
for lookups, so all that code that I wrote to implement the process
described above has been ripped out in the last two weeks!
But it was a valuable lesson that perhaps others might benefit from
hearing about.
While I realize you're in the US, just in case you ever have users should
have a different Short Date format, you're safer using
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate=" & _
Format(Date(), "\#yyyy\-mm\-dd\#")
--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)
I see that my code forgot the hash marks around the date:DoCmd.OpenForm "NorthWeldDailyfrm", , , [txtDate=#" & Date() & "#[/QUOTE]
I also see that, you need more than today's date, so you'll need an
unbound text box on the search form, I'll call this one txtDate. David
added, correctly, that you can just open the form without checking. So
now, try:DoCmd.OpenForm "NorthWeldDailyfrm", , , [txtDate=#" & txtDate & "#[/QUOTE]
which is sufficient to do what you want. Now what happens here is that if
there is an existing date, it will open to it, if there is no existing
record, it will open a blank record. Others here have shown you code on
how to prevent additions.Under no conditions do you need a "holding" table. You never ever store a
record twice. Even audit history records are there because someone changed
the original. I'd stay well clear of the person who gave you that idea,
since the no nothing about relational databases. That kind of advice
typically comes from programmers who think code solves everything and will
get you in more database trouble than any real database programmer wants
to deal with. When I see that kind of activity, I generally rewrite
everything from scratch.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com- Hide quoted text -
- Show quoted text -
Sorry,.,,, I'm still missing something here.....
I am copying and pasting your suggestions and I am getting compile
errors
and syntax errors... VBA is still pretty new to me...where would the
other
] bracket go?
While I realize you're in the US, just in case you ever have users should
have a different Short Date format, you're safer using
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate=" & _
Format(Date(), "\#yyyy\-mm\-dd\#")
--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)
I see that my code forgot the hash marks around the date:DoCmd.OpenForm "NorthWeldDailyfrm", , , [txtDate=#" & Date() & "#[/QUOTE]
I also see that, you need more than today's date, so you'll need an
unbound text box on the search form, I'll call this one txtDate. David
added, correctly, that you can just open the form without checking. So
now, try:DoCmd.OpenForm "NorthWeldDailyfrm", , , [txtDate=#" & txtDate & "#[/QUOTE]
which is sufficient to do what you want. Now what happens here is that if
there is an existing date, it will open to it, if there is no existing
record, it will open a blank record. Others here have shown you code on
how to prevent additions.Under no conditions do you need a "holding" table. You never ever store a
record twice. Even audit history records are there because someone changed
the original. I'd stay well clear of the person who gave you that idea,
since the no nothing about relational databases. That kind of advice
typically comes from programmers who think code solves everything and will
get you in more database trouble than any real database programmer wants
to deal with. When I see that kind of activity, I generally rewrite
everything from scratch.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com- Hide quoted text -
- Show quoted text -
I am using the following and it works just great:
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate = Date()"
End Sub
One simple line and it accomplishes the desired results. Thank you
for all your help.
While I realize you're in the US, just in case you ever have users
should have a different Short Date format, you're safer using
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate=" & _
Format(Date(), "\#yyyy\-mm\-dd\#")
I am using the following and it works just great:
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate = Date()"
End Sub
David said:I would change that to:
DoCmd.OpenForm "NorthWeldDailyfrm", , , "txtDate =#" & Date() & "#"
David W. Fenton said:Or using DateSerial().
I don't see how that makes the problem any easier.
As was pointed out else-thread, "txtDate = Date()" will work. If
the date is specified outside of the quotes, then you must delimit
using # characters, and you must put it in a format Access will
recognize correctly.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.