Solved

If VBYes then remove some info

Posted on 2006-06-22
12
776 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

867 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

19 Experts available now in Live!

Get 1:1 Help Now