Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Trying to clean up null on close

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RobUCSD - 11 Jun 2007 01:25 GMT
With the code below I'm trying to clean up nulls on close (via cmd button),
its propting for a parameter:

"Forms!frmPtDemographicNew!frmVisitNewEdit!fsubRNnotes.Form!fldRNnotes."

DoCmd.RunSQL "DELETE * FROM tblRNnotes WHERE [fldRNnotes] = [Forms]!
[frmPtDemographicNew]![frmVisitNewEdit]![fsubRNnotes].Form![fldRNnotes] Is
Null"
  DoCmd.Close
 
I'm not sure what its asking for. Thanks for your help in advance, Rob
SteveS - 11 Jun 2007 22:28 GMT
What it is saying it that SQL doesn't understand what

"[Forms]![frmPtDemographicNew]![frmVisitNewEdit]![fsubRNnotes].Form![fldRNnotes]"

means.

It is a reference to a control on a page, but you have it *inside* the
quotes. To get the value of the control, it needs to be outside the quotes.
You need to concatenate the form reference to the string. (see below)

Also, the forms reference looks wrong. Is this a nested subform?

Try rewriting it like this:

'-----------------------------------
Dim strSQL as String

  strSQL = "DELETE * FROM tblRNnotes
  strSQL = strSQL  & " WHERE [fldRNnotes] = "      
  strSQL = strSQL  &
[Forms]![frmPtDemographicNew]![frmVisitNewEdit]![fsubRNnotes].Form![fldRNnotes]
  strSQL = strSQL  & " Is Null"

'for debugging-----
  DoCmd.Print strSQL
'  or
  'MsgBox strSQL
'------------------

  DoCmd.RunSQL
  DoCmd.Close

'------end-----------------------------

In looking at the SQL statement, I question the WHERE clause.
You have (I am going to shorten the reference to the form)

"WHERE [fldRNnotes] = " & Me.[fldRNnotes] & " Is Null"

This should (I didn't test) result is TRUE or FALSE

So it would eval to  ..."WHERE TRUE Is Null" or  ..."WHERE FALSE Is Null"

It would never be true and no records would ever be deleted.

Would "...WHERE  [fldRNnotes] Is Null"  work to delete the records you want
deleted?

Or you will have to write a delete query that has a WHERE clause that is the
conditions of the sub-sub form to select the records to be deleted.

One last thing. If you don't want the warnings that "DoCmd.RunSQL" gives,
change

  DoCmd.RunSQL      to         Currentdb.Execute strSQL

HTH
Signature

Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

> With the code below I'm trying to clean up nulls on close (via cmd button),
> its propting for a parameter:
[quoted text clipped - 7 lines]
>  
>  I'm not sure what its asking for. Thanks for your help in advance, Rob
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.