Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

runtime error 94 (ignore or skip if null)

Discussion in 'Information Technology' started by JNT, Jul 28, 2006.

  1. JNT

    JNT
    Expand Collapse
    Guest

    tblMarketplace:
    column name: Marketplace HOU_CCC ATL_CCC
    field value Bay Area CEN Atlanta, Ga
    DesertSW GLD FLD
    Mountain West Houston, Tx
    No Central Cal
    Pacific Nw
    So California

    VB CODE:

    qry = "SELECT tbltopmarketplace.* FROM tbltopmarketplace WHERE
    ((tbltopmarketplace.[CSC COD])=F_aging2()) AND ((tbltopmarketplace.[Key
    Indicator]) IS NULL);"


    db.QueryDefs.Delete "qryexportTopAccounts"
    Set qdf = db.CreateQueryDef("qryexportTopAccounts", qry)

    tbl = "tblmarketplace"
    myexportfile = "C:\My Documents\Top HOU CCC Key.xls"
    Set db = CurrentDb
    Set rst = db.OpenRecordset(tbl)
    rst.MoveFirst
    Do Until rst.EOF
    vaging2 = rst.Fields("HOU_CCC")
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
    "qryexportTopAccounts", myexportfile, True, vaging2
    rst.MoveNext
    Loop
    rst.Close

    Set rst = Nothing
    Set db = Nothing

    Exit_cmdRunQuery_Click:
    Exit Sub


    Err_cmdRunQuery_Click:
    If Err.Number = 94 Then
    Resume Next
    Else
    MsgBox Err.Description
    Resume Exit_cmdRunQuery_Click
    End If

    I am trying to export out into excel by "HOU_CCC" field in tblmarketplace.
    Because there are blank fields it gives me the runtime error 94 (invalid use
    of null).

    How do I go about ignoring that code?

    Thank you,
     
  2. Loading...


  3. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    If you want to skip those rows that don't have a value, try:

    Do Until rst.EOF
    If Not IsNull(rst.Fields("HOU_CCC")) Then
    vaging2 = rst.Fields("HOU_CCC")
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
    "qryexportTopAccounts", myexportfile, True, vaging2
    End If
    rst.MoveNext
    Loop


    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "JNT" <JNT@discussions.microsoft.com> wrote in message
    news:39C56CF5-AAC9-4939-BC3C-9A74B7F18604@microsoft.com...
    > tblMarketplace:
    > column name: Marketplace HOU_CCC ATL_CCC
    > field value Bay Area CEN Atlanta, Ga
    > DesertSW GLD FLD
    > Mountain West Houston, Tx
    > No Central Cal
    > Pacific Nw
    > So California
    >
    > VB CODE:
    >
    > qry = "SELECT tbltopmarketplace.* FROM tbltopmarketplace WHERE
    > ((tbltopmarketplace.[CSC COD])=F_aging2()) AND ((tbltopmarketplace.[Key
    > Indicator]) IS NULL);"
    >
    >
    > db.QueryDefs.Delete "qryexportTopAccounts"
    > Set qdf = db.CreateQueryDef("qryexportTopAccounts", qry)
    >
    > tbl = "tblmarketplace"
    > myexportfile = "C:\My Documents\Top HOU CCC Key.xls"
    > Set db = CurrentDb
    > Set rst = db.OpenRecordset(tbl)
    > rst.MoveFirst
    > Do Until rst.EOF
    > vaging2 = rst.Fields("HOU_CCC")
    > DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
    > "qryexportTopAccounts", myexportfile, True, vaging2
    > rst.MoveNext
    > Loop
    > rst.Close
    >
    > Set rst = Nothing
    > Set db = Nothing
    >
    > Exit_cmdRunQuery_Click:
    > Exit Sub
    >
    >
    > Err_cmdRunQuery_Click:
    > If Err.Number = 94 Then
    > Resume Next
    > Else
    > MsgBox Err.Description
    > Resume Exit_cmdRunQuery_Click
    > End If
    >
    > I am trying to export out into excel by "HOU_CCC" field in tblmarketplace.
    > Because there are blank fields it gives me the runtime error 94 (invalid

    use
    > of null).
    >
    > How do I go about ignoring that code?
    >
    > Thank you,
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page