Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

If VBYes then remove some info

Posted on 2006-06-22
12
Medium Priority
?
800 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

597 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