also check isnull(adorecordset.fields("wire_length").value) before you do
any action on the field.  Often fields that should contain valid data don't.
Never assume that just because you have a valid record, that it contains
either valid data, or any data at all.  It does not matter how fool proof
you try and make your system, someone will find a way to make sure they have
a GIGO situation.

Matt

----- Original Message ----- 
From: "warren ang" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 24, 2004 7:17 PM
Subject: RE: [vbhelp] An easy database question


> Try checking if their is records in the recordset
>
> -----
>
> if adorecordset.eof then
> ----- msgbox ---
> endif
>
> ---------
>
> if recordset has records the function adorecordset.eof will return false
> else true
>
> -----Original Message-----
> From: Julian Holt [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 24, 2004 5:10 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [vbhelp] An easy database question
>
>
> Brilliant - Thanks Warren - works a treat.
>
> One additional question.
> If I pass a partnumber that is not found by the SQL I get a "Invalid use
of
> Null" error when the command
>
> adorecordset.fields("wire_length").value
>
> is executed - I.E I assume wire_length is created but doesn't contain any
> fields (or at least they are Null)?
>
> Is there a correct way to check for this (Null) without resorting to an on
> error goto (or similar)?
>
> Thanks again
>
>
> Julian
>
>   -----Original Message-----
>   From: warren ang [mailto:[EMAIL PROTECTED]
>   Sent: 24 May 2004 10:07
>   To: [EMAIL PROTECTED]
>   Subject: RE: [vbhelp] An easy database question
>
>
>
>   you could use the below code to access sum(length):
>
>   adorecordset.fields("wire_length").value
>
>   -----Original Message-----
>   From: Julian Holt [mailto:[EMAIL PROTECTED]
>   Sent: Monday, May 24, 2004 4:43 PM
>   To: [EMAIL PROTECTED]
>   Subject: [vbhelp] An easy database question
>
>
>   (Sorry for the cross posting)
>
>   Guys
>
>   I am getting into SQL (wow powerful or what?)
>
>   Anyway I have a really simple question (and embarrassing one).
>   I am opening the DB and passing in a SQL query that sums a few fields
and
>   returns the value in a 'temporary' table called wire_length
>
>   eg SELECT SUM(Length) AS wire_length FROM LOOP WHERE PartNo = '610972'
>
>   I have checked this query in Access and it works ok. I now want to put
it
>   into VB
>
>   Here is the code
>
>       Set adoConnection = New ADODB.Connection
>       Set adoRecordset = New ADODB.Recordset
>
>       strTemp = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
> strLoopName
>   & ";Persist Security Info=False"
>       adoConnection.Open strTemp
>
>       strSQL = "SELECT SUM(Length) AS wire_length FROM LOOP WHERE PartNo =
> '"
>   & strPartNo & "'"
>
>       adoRecordset.Open strSQL, adoConnection
>
>   '    adoRecordset.Close
>   '    adoConnection.Close
>       Set adoConnection = Nothing
>       Set adoRecordset = Nothing
>
>   Question
>
>   How do I access the summed value in VB???? To date I have only used SQL
to
>   add and delete items in the DB so this is new stuff for me.
>
>   I.E I want to add a line like sngSum = ???????????
>
>   Told you it was simple :-)
>
>   Oh and another one,,,
>
>   Why is it that I have to comment out the lines adoRecordset.Close and
>   adoConnection.Close when doing a query?
>   Does a query automatically close the DB???
>
>
>   Mucho thanks
>
>
>
>   Julian Holt
>
>
>   [Non-text portions of this message have been removed]
>
>
>
>
>
>   '// =======================================================
>       Rules : http://ReliableAnswers.com/List/Rules.asp
>       Home  : http://groups.yahoo.com/group/vbHelp/
>       =======================================================
>       Post  : [EMAIL PROTECTED]
>       Join  : [EMAIL PROTECTED]
>       Leave : [EMAIL PROTECTED]
>   '// =======================================================
>
>   Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
############################################################################
> #########
>   This e-mail message has been scanned for Viruses and Content and cleared
>   by NetIQ MailMarshal
>
>
############################################################################
> #########
>
>
>
>   '// =======================================================
>       Rules : http://ReliableAnswers.com/List/Rules.asp
>       Home  : http://groups.yahoo.com/group/vbHelp/
>       =======================================================
>       Post  : [EMAIL PROTECTED]
>       Join  : [EMAIL PROTECTED]
>       Leave : [EMAIL PROTECTED]
>   '// =======================================================
>
>
>
>         Yahoo! Groups Sponsor
>               ADVERTISEMENT
>
>
>
>
>
> --------------------------------------------------------------------------
--
> --
>   Yahoo! Groups Links
>
>     a.. To visit your group on the web, go to:
>     http://groups.yahoo.com/group/vbhelp/
>
>     b.. To unsubscribe from this group, send an email to:
>     [EMAIL PROTECTED]
>
>     c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> '// =======================================================
>     Rules : http://ReliableAnswers.com/List/Rules.asp
>     Home  : http://groups.yahoo.com/group/vbHelp/
>     =======================================================
>     Post  : [EMAIL PROTECTED]
>     Join  : [EMAIL PROTECTED]
>     Leave : [EMAIL PROTECTED]
> '// =======================================================
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
############################################################################
#########
> This e-mail message has been scanned for Viruses and Content and cleared
> by NetIQ MailMarshal
>
############################################################################
#########
>
>
>
> '// =======================================================
>     Rules : http://ReliableAnswers.com/List/Rules.asp
>     Home  : http://groups.yahoo.com/group/vbHelp/
>     =======================================================
>     Post  : [EMAIL PROTECTED]
>     Join  : [EMAIL PROTECTED]
>     Leave : [EMAIL PROTECTED]
> '// =======================================================
>
> Yahoo! Groups Links
>
>
>
>
>
>



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~-> 


'// =======================================================
    Rules : http://ReliableAnswers.com/List/Rules.asp
    Home  : http://groups.yahoo.com/group/vbHelp/
    =======================================================
    Post  : [EMAIL PROTECTED]
    Join  : [EMAIL PROTECTED]
    Leave : [EMAIL PROTECTED]
'// =======================================================
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/vbhelp/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 

Reply via email to