?
Solved

How to modity code in timer sub to be a conditional

Posted on 2009-04-01
14
Medium Priority
?
329 Views
Last Modified: 2013-12-25
Ok, my question is how can i switch between to way of displaying the text associated with the blinking.  Meaning if this is true show this (blinking text) if not show this ( non-blinking text) same value.  When i wrap the with block in a if statment using a fuction for the true/ false value is hangs Access.  Any ideas !!???
Private Sub Form_Load()
     custAgent(sn("cust_number")) Then
            Me.TimerInterval = 90
            Forms!f_builder.txtXCustNum = sn("Customer_number")
            Forms!f_builder.txtXCustNum.ForeColor = 255
        
        Else
            Forms!f_builder.txtXCustNum = IIf(IsNull(sn("Customer_number")), "", sn("Customer_number"))
        End If
 
end sub
 
Private Sub Form_Timer()
 
    With Forms!f_builder.txtXCustNum
        .ForeColor = (IIf(.ForeColor = vbRed, vbWhite, vbRed))
    End With
 
 
    Me!lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
End Sub

Open in new window

0
Comment
Question by:thirsty4knowledge
  • 5
  • 5
  • 4
14 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 24042909
Is txtXCustNum part of the form you are in now or another form? if on current form, you can just do Me.txtXCustNum


Your timerinterval is a bit short, less than a second? extend it a little
0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 24042941
Your IF statement is not formed correctly.

You have:
custAgent(sn("cust_number")) Then

You are missing the Keyword IF.  You also need to be sure that custAgent() is returning a boolean (true/false) value.

HTH
- Anthony
0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 24042957
good catch rockiroads.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:thirsty4knowledge
ID: 24042984
Ok, this is a copy/ paste error but the error still has merrit.  I cant find a way to set sub_form timer based on a conditional!  Any ideas... also the function dose in fact return a boolean value.
0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 24043102
Try this code.

Also, modify your timer interval to something higher, as rockiroads stated.
Private Sub Form_Load()
     If custAgent(sn("cust_number")) Then
            Me.TimerInterval = 90 
            Forms!f_builder.txtXCustNum = sn("Customer_number")
            Forms!f_builder.txtXCustNum.ForeColor = 255 
            Me.Timer.Enabled = True
        Else
            Forms!f_builder.txtXCustNum = IIf(IsNull(sn("Customer_number")), "", sn("Customer_number"))
            Me.Timer.Enabled = False
        End If
 
end sub
 
Private Sub Form_Timer()
 
    With Forms!f_builder.txtXCustNum
        .ForeColor = (IIf(.ForeColor = vbRed, vbWhite, vbRed))
    End With
 
    Me!lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
End Sub

Open in new window

0
 
LVL 10

Expert Comment

by:ALaRiva
ID: 24043114
Additional Note:
Set the Timer's enabled property default to FALSE.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24043139
Cheers ALaRiva :)

You can switch off the timer, if thats what you mean Me.TimerInterval = 0 switches it off.
0
 

Author Comment

by:thirsty4knowledge
ID: 24043145
rockiroads:,

Yes,  txtXCustNum is part of the current vlue, im not sure how that solves the problem?  I would love something like below but the function contains loops that seem to tie up resources.
Private Sub Form_Timer()
 
  if custAgent(cust_number) Then
    With Forms!f_builder.txtXCustNum
        .ForeColor = (IIf(.ForeColor = vbRed, vbWhite, vbRed))
    End With
  end if 
 
 
    Me!lblClock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
End Sub

Open in new window

0
 
LVL 65

Accepted Solution

by:
rockiroads earned 1400 total points
ID: 24043202
it wont solve the problem but tidies up your code and was just a recommendation. there is no need to reference a form field like that when you can simply do Me.txtXCustNum

Set the TimerInterval to blink it, set it to 0 to stop it
0
 

Author Comment

by:thirsty4knowledge
ID: 24043536
ok, guess i was making it harder than what it need to be.. thanks for everyones.. quick responses!  
0
 

Author Closing Comment

by:thirsty4knowledge
ID: 31565510
You are the man!!
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24043578
No worries. Did you try AlaRiva's approach is enabling/disabling the timer? Looks like that would work also.
0
 

Author Comment

by:thirsty4knowledge
ID: 24043607

I tried but it didn't like me trying to access the timer object like that....? So plus i need to test and push up to production like yesterday.. thanks again!
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 24043684
Cool, regarding me.timer then, it looks like its a vb thing, and not available in vba.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

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…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

862 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