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 / May 2008

Tip: Looking for answers? Try searching our database.

If not executing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CJ - 30 May 2008 17:50 GMT
Hi Groupies:

I would like my form to check the warranty status of my equipment. If the
warranty expiry date is less than today and the warranty field is still
checked, I would like the warranty field to uncheck and a message box to pop
up.

I have the following code in the OnCurrent event of my form:

Dim MyDate
MyDate = Date

If (Me.dtmWarrantyExpiry < MyDate) And (Me.ysnWarranty = True) Then
   Me.ysnWarranty = False
   MsgBox "Warranty has expired for this item", vbOKOnly, "No Warranty"
   Me.SKU_Number.SetFocus
End If

Although I do not get any error messages, nothing happens at all between
records.

Any ideas?

Signature

Thanks for taking the time!

CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!

PJFry - 30 May 2008 18:20 GMT
It is probably around the =True section of your If statement.  

When I run into these problems I do something like this on the OnCurrent Event
MsgBox Me.dtmWarrantyExpiry
MsgBox Me.ysnWarranty
MsgBox MyDate

This will tell you exactly what Access sees as a value and you can adjust
your statement to reflect the correct values (if they are not already
correct).

Try that and write back.

PJ

> Hi Groupies:
>
[quoted text clipped - 18 lines]
>
> Any ideas?
CJ - 30 May 2008 19:03 GMT
Hi PJ

OK, so now my code is:

Private Sub Form_Current()

Dim MyDate
MyDate = Date

MsgBox Me.dtmWarrantyExpiry
MsgBox Me.ysnWarranty
MsgBox MyDate

If (Me.dtmWarrantyExpiry < MyDate) And (Me.ysnWarranty = -1) Then
   Me.ysnWarranty = 0
   MsgBox "Warranty has expired for this item", vbOKOnly, "TOG Systems"
   Me.SKU_Number.SetFocus
End If

End Sub

The values in the message boxes are what I expect to see:

Warranty Expiry: May 29 2007
Warranty -1
My Date: May 30 2008

So, the warranty expired last year, the warranty check box needs to change
to 0 and the message box needs to show up.

Signature

CJ

> It is probably around the =True section of your If statement.
>
[quoted text clipped - 35 lines]
>>
>> Any ideas?
CJ - 30 May 2008 19:27 GMT
Fixed it!

dtmWarrantyExpiry is a calculated field that returns a date. It's one of
those instances where you need to perform the calculation in order for the
comparison to work. So, my code is:

Dim MyDate
MyDate = Date

If (Me.Date_Purchased + Me.sngWarrantyDuration) And (Me.ysnWarranty = -1)
Then
   Me.ysnWarranty = 0
   MsgBox "Warranty has expired for this item", vbOKOnly, "TOG Systems"
   Me.SKU_Number.SetFocus
End If

Thanks for steering me in the right direction!

CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!

> Hi PJ
>
[quoted text clipped - 66 lines]
>>>
>>> Any ideas?
CJ - 30 May 2008 19:49 GMT
Sorry, there was an error in the code I posted.

It should have been :

Dim MyDate
MyDate = Date

If (Me.Date_Purchased + Me.sngWarrantyDuration) < MyDate And (Me.ysnWarranty
= -1) Then
   Me.ysnWarranty = 0
   MsgBox "Warranty has expired for this item", vbOKOnly, "TOG Systems"
   Me.SKU_Number.SetFocus
End If

CJ

> Fixed it!
>
[quoted text clipped - 91 lines]
>>>>
>>>> Any ideas?

Signature

Thanks for taking the time!

CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!

 
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.