A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help With SQL Statement



 
 
Thread Tools Display Modes
  #1  
Old May 21st, 2010, 04:15 PM posted to microsoft.public.access
Yes2man
external usenet poster
 
Posts: 7
Default Help With SQL Statement

Hi everyone...back to the well for help...

Here is the code:
strSQL = "SELECT * FROM [Walk Around Schedule: All Items] WHERE [Begin Date]
= #" & walkdate & "#"

Set rswalkaround = dbwalkaround.OpenRecordset(strSQL)

....where 'walkdate' is the value of a text field.

It works just fine BUT the recordset contains only the first record meeting
the criteria from the table, although I know there are multiple records that
meet the criteria in that table...what am I missing?

rswalkaround.recordcount returns 1!

Any/All help greatly appreciated!

Regards
yes2man
  #2  
Old May 21st, 2010, 04:39 PM posted to microsoft.public.access
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Help With SQL Statement

One possibility is that the Begin Date column contains values with non-zero
times of day. A common cause of this is the inappropriate use of the Now()
function to insert the current date into the column; the Date() function
should be used for this. To correct any instances of this, which might not
be readily apparent when you look at the data, a simple update query can be
executed:

UPDATE [Walk Around Schedule: All Items]
SET [Begin Date] = DATEVALUE([Begin Date])
WHERE [Begin Date] IS NOT NULL;

Another thing you should do is to ensure that the date literal being built
into the string expression is in an internationally unambiguous date format.
The ISO format for date notation is YYYY-MM-DD, so this is a good one to use:

strSQL = _
"SELECT * FROM [Walk Around Schedule: All Items] " & _
"WHERE [Begin Date] = #" & _
Format(walkdate,"yyyy-mm-dd") & "#"

Another thing you can do is to ensure the recordset is filled by moving to
the last record:

Set rswalkaround = dbwalkaround.OpenRecordset(strSQL)
rswalkaround.MoveLast

If you then want to iterate through the recordset move back to the first
record:

rswalkaround.MoveFirst

Ken Sheridan
Stafford, England

yes2man wrote:
Hi everyone...back to the well for help...

Here is the code:
strSQL = "SELECT * FROM [Walk Around Schedule: All Items] WHERE [Begin Date]
= #" & walkdate & "#"

Set rswalkaround = dbwalkaround.OpenRecordset(strSQL)

...where 'walkdate' is the value of a text field.

It works just fine BUT the recordset contains only the first record meeting
the criteria from the table, although I know there are multiple records that
meet the criteria in that table...what am I missing?

rswalkaround.recordcount returns 1!

Any/All help greatly appreciated!

Regards
yes2man


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/201005/1

  #3  
Old May 21st, 2010, 04:41 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Help With SQL Statement

Your WHERE clause is only looking for a single date. Did you perhaps mean

"..WHERE [Begin Date] #" & walkdate & "#"

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"yes2man" wrote in message
...
Hi everyone...back to the well for help...

Here is the code:
strSQL = "SELECT * FROM [Walk Around Schedule: All Items] WHERE [Begin
Date]
= #" & walkdate & "#"

Set rswalkaround = dbwalkaround.OpenRecordset(strSQL)

...where 'walkdate' is the value of a text field.

It works just fine BUT the recordset contains only the first record
meeting
the criteria from the table, although I know there are multiple records
that
meet the criteria in that table...what am I missing?

rswalkaround.recordcount returns 1!

Any/All help greatly appreciated!

Regards
yes2man



  #4  
Old May 21st, 2010, 05:02 PM posted to microsoft.public.access
Daniel Pineault
external usenet poster
 
Posts: 658
Default Help With SQL Statement

You state :

rswalkaround.recordcount returns 1

Are you sure! Did you use rswalkaround.MoveLast before performing your
recordcount, if not your count will be invalid!

See: http://www.devhut.net/index.php?lang...000011#recsets
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"yes2man" wrote:

Hi everyone...back to the well for help...

Here is the code:
strSQL = "SELECT * FROM [Walk Around Schedule: All Items] WHERE [Begin Date]
= #" & walkdate & "#"

Set rswalkaround = dbwalkaround.OpenRecordset(strSQL)

...where 'walkdate' is the value of a text field.

It works just fine BUT the recordset contains only the first record meeting
the criteria from the table, although I know there are multiple records that
meet the criteria in that table...what am I missing?

rswalkaround.recordcount returns 1!

Any/All help greatly appreciated!

Regards
yes2man

  #5  
Old May 21st, 2010, 05:04 PM posted to microsoft.public.access
Craig Lindgren
external usenet poster
 
Posts: 2
Default Help With SQL Statement

the second coming of christ to earth.?
www.musecrafters.com/ocean
must read.

"yes2man" wrote in message
...
Hi everyone...back to the well for help...

Here is the code:
strSQL = "SELECT * FROM [Walk Around Schedule: All Items] WHERE [Begin
Date]
= #" & walkdate & "#"

Set rswalkaround = dbwalkaround.OpenRecordset(strSQL)

...where 'walkdate' is the value of a text field.

It works just fine BUT the recordset contains only the first record
meeting
the criteria from the table, although I know there are multiple records
that
meet the criteria in that table...what am I missing?

rswalkaround.recordcount returns 1!

Any/All help greatly appreciated!

Regards
yes2man


  #6  
Old May 21st, 2010, 05:17 PM posted to microsoft.public.access
Yes2man
external usenet poster
 
Posts: 7
Default Help With SQL Statement

THAT WAS IT!! Stupid...so deep didn't even see it...thanks a ton!

"Daniel Pineault" wrote:

You state :

rswalkaround.recordcount returns 1

Are you sure! Did you use rswalkaround.MoveLast before performing your
recordcount, if not your count will be invalid!

See: http://www.devhut.net/index.php?lang...000011#recsets
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"yes2man" wrote:

Hi everyone...back to the well for help...

Here is the code:
strSQL = "SELECT * FROM [Walk Around Schedule: All Items] WHERE [Begin Date]
= #" & walkdate & "#"

Set rswalkaround = dbwalkaround.OpenRecordset(strSQL)

...where 'walkdate' is the value of a text field.

It works just fine BUT the recordset contains only the first record meeting
the criteria from the table, although I know there are multiple records that
meet the criteria in that table...what am I missing?

rswalkaround.recordcount returns 1!

Any/All help greatly appreciated!

Regards
yes2man

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.