Solved

If VBYes then remove some info

Posted on 2006-06-22
12
772 Views
Last Modified: 2012-08-14
This is part of a Before Update event:

            If Me.CertificationType.Value = "Permanent Decertification" Then
                Me.Visible = False
                If MsgBox("You have selected Permanent Decertification." & vbCrLf & vbCrLf _
                   & "By making this selection you will be removing dates pertinent to this " _
                   & "individuals CPRP Certification process." & vbCrLf & vbCrLf _
                   & "THIS REMOVAL ON INFORMATION CAN NOT BE UNDONE.  Do you wish to continue " _
                   & "with this selection?", vbYesNo) = vbYes Then
                   
                    Set PDQrs = db.OpenRecordset("tblDatesRemoved")
                   
                    With PDQrs
                        .AddNew
                        !EmpNo = Me.EmpNo
                        !CertificationType = Me.CertificationType.Value
                        !InitialInterview = Me.InitialInterview
                        !Date3180ToCOReview = Me.Date3180ToCOReview
                        !Date3180ToHR = Me.Date3180ToHR
                        !Date3180FromHR = Me.Date3180FromHR
                        !Date3180ToClinic = Me.Date3180ToClinic
                        !Date3180FromClinic = Me.Date3180FromClinic
                        !Date3180ToCOFinal = Me.Date3180ToCOFinal
                        !CertificationDate = Me.CertificationDate
                        .Update
                    End With
                   
                    Set PDQrs = Nothing
                   
                    Me.CertificationType = ""
                    Me.InitialInterview = ""
                    Me.Date3180ToCOReview = ""
                    Me.Date3180ToHR = ""
                    Me.Date3180FromHR = ""
                    Me.Date3180ToClinic = ""
                    Me.Date3180FromClinic = ""
                    Me.Date3180ToCOFinal = ""
                    Me.CertificationDate = ""
                   
                    Me.Visible = True
                   
Everything works great...until I want to reset the values of other controls on my form.

What do I need to do to make this work?

Thanks!
Lena
0
Comment
Question by:LenaWood
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 27

Expert Comment

by:jjafferr
ID: 16962166
Hi LenaWood,

You can reset the string controls by assigning "" to them,
but for numbers, you have to assign a 0 (zero)

jaffer
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 16962182
I would suggest you putting a remark on all the Reset code items, then checking them 1 at a time
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 16962184
use the Tag property of the controls.

dim ctl as control
for each ctl i me.controls
  if ctl.tag="somevalue" then
     ctl.name=""
  end if

next
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 16962209
Hey Lena

You'd not change the values of controls in the active form in a BeforeUpdate event.
Normally you'd test then - make a decision to proceed or not, and then make changes afterwards.
0
 
LVL 10

Author Comment

by:LenaWood
ID: 16962263
OK....my recordset works and all the information is put into the table.  What I can't do is remove the dates from my controls on my form.

I have tried Me.CertificationType = Null and Me.CertificationType = "" with no luck.  I have even made sure that zero lengths are allowed. (They weren't but changing it didn't help).  CertificationType is a text field.

The error message I get is:

The macro or function set to the Before Update or Validation Rule property for this field is preventing Microsoft Access from saving the data in the field.

I am looking at this knowing I should know how to do this, but it all is looking kinda foriegn to me.  Thank goodness the weekend is almost here.

Lena
0
 
LVL 10

Author Comment

by:LenaWood
ID: 16962281
LPurvis - I thought I was testing by asking the question if they want to proceed.  If they say yes I want to proceed.  It is the proceeding part that I am having trouble with.  I am starting to really HATE this database haha.

Lena
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 16962330
Is it a control or the form's beforeupdate event we're talking about?
0
 
LVL 10

Author Comment

by:LenaWood
ID: 16962374
The code I pasted is on a controls before update event.  I think I am trying to automate far too much!

Lena
0
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 16962393
No - that should be OK.

But in what way is it going wrong?
Where are you getting an error - and which error is it?

Are the specified fields allowed to be a zero length string?
(I'd always set mine to Null.  Always always always).

Did I mention always?
0
 
LVL 10

Author Comment

by:LenaWood
ID: 16962446
Error is:

The macro or function set to the Before Update or Validation Rule property for this field is preventing Microsoft Access from saving the data in the field.

It won't change the values to "" or Null

Yes, they are allowed to be zero length.  All of them are dates except one, and I didn't see an allow Zero length on the date fields in the table.

I have it working, just not sure it is how I should have done it.  I created a publically declared blnChangeDates as a boolean.  When the form is opened I set it to false.  When I run the code pasted above instead of changing the dates then, I changed blnChangeDates to true.  On the button that closes that form, I have it check for the value of blnChangeDates and if it is true, I have it set the values of those controls to "" (but will ALWAYS change it to null).

Just not sure what I am doing wrong in the first place.
Lena
0
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 500 total points
ID: 16962473
I'd do exactly as you describe - but set your boolean flag to true in the BeforeUpdate - and perform your changes in the Afterupdate event based on the state of that flag.
(Remember to reset the flag in the afterupdate event too ;-)
0
 
LVL 10

Author Comment

by:LenaWood
ID: 16962805
I tried this in the afterupdate event (of the control) and had no luck with it working.  Probably something that I did wrong.  I will try it again.

Thanks!
Lena
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now