Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Buton to clear Y/N field in 5 tables. 2

Status
Not open for further replies.

cimoli

Technical User
Jul 30, 2010
207
0
0
US
I have a main form with 5 subforms. I use a yes/no field in each of the 5 underlying tables to manage my picks per subform.
EG I checkmark a few customer type in the first subform. I checkmark cust classes. etc.

However, I need to reset the 5 subforms to have an empty y/n when I am done.

I have a query inside EACH subform to allow me to clear or reset the y/n field.
That is 5 buttons that I hit. But I would like to consolidate into ONE Clear or reset button.

I inserted the sql that works for each button and tried placing them together (see below). But the One button method bombed out.
Anyway to do this? Thank You.

------------------------------------------------------------------------
Private Sub cmdClearALL_Click()

UPDATE tblCustType SET tblCustType.PickCusTypeID = Null;
UPDATE tblCusClass SET tblCusClass.PickCusclassID = Null;
UPDATE tblRep SET tblRep.PickRepID = Null;
UPDATE tblMailRegion SET tblMailRegion.PickMailRegionID = Null;
UPDATE tblReferredBy SET tblReferredBy.PickReferredBy = Null;

End Sub
 
bombed out" that's the technical expression I am not familiar with... :-(

Did you try something like this:

Code:
Private Sub cmdClearALL_Click()
Dim strSQL As String 

strSQL = " UPDATE tblCustType   SET PickCusTypeID    = Null"
DB.Execute strSQL
strSQL = " UPDATE tblCusClass   SET PickCusclassID   = Null"
DB.Execute strSQL
strSQL = " UPDATE tblRep        SET PickRepID        = Null"
DB.Execute strSQL
strSQL = " UPDATE tblMailRegion SET PickMailRegionID = Null"
DB.Execute strSQL
strSQL = " UPDATE tblReferredBy SET PickReferredBy   = Null"
DB.Execute strSQL

End Sub

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Hi Andrzejek - I pasted in your code from above. I ran the main form button.
It sends me to debug at the following spot. It turned yellow.

Db.Execute strSQL

Any ideas? thanks much.

 
Try:[tt]
Docmd.RunSQL (strSQL, false) [/tt]
instead.


Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Hi. I tried Andrzejek but it did not work. I do not know how to handle the idea of IDMF since I am not an SQL person.

I made a mini file for testing. If you don't mind. The item in question is in the On Click of
the red CLEAR ALL button on the form.

Thanks you. You both seem close to solving the matter.

 
 http://files.engineering.com/getfile.aspx?folder=5eff0b13-c1a0-4ba2-9149-94ea34cc33ba&file=CSI_2016-06-07_11am_mini.zip
Got this Clear ALL button to work as follows. FYI. thanks alot.

Private Sub cmdClearResortID_Click()

Dim strSQL As String

strSQL = " UPDATE tblCustType SET PickCusTypeID = Null"
CurrentDb.Execute strSQL

strSQL = " UPDATE tblCusClass SET PickCusclassID = Null"
CurrentDb.Execute strSQL

strSQL = " UPDATE tblRep SET PickRepID = Null"
CurrentDb.Execute strSQL

strSQL = " UPDATE tblMailRegion SET PickMailRegionID = Null"
CurrentDb.Execute strSQL

strSQL = " UPDATE tblReferredBy SET PickReferredBy = Null"
CurrentDb.Execute strSQL

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top