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

x
?
Solved

Microsoft Access screen flashing on update

Posted on 2012-03-21
10
Medium Priority
?
532 Views
Last Modified: 2012-03-22
Hi

The code below works fine execpt that the screen flashes when the code executes.

Please make it stop!


Private Sub MyTag_Click()
Dim rs As DAO.Recordset: Set rs = GetRecordSet(Me.[Stock #])
If rs.RecordCount = 0 Then Exit Sub
rs.Edit

If LCase(Nz(rs![MyTag])) = "y" Then
rs![MyTag] = "":
Else: rs![MyTag] = "Y": End If

rs.Update: rs.Close: Set rs = Nothing
MyTag.SelLength = 0: MyTag.SelStart = 0
Refresh
End Sub
0
Comment
Question by:peispud
[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
  • 4
  • 3
  • 3
10 Comments
 
LVL 58
ID: 37750419
Well you've got a refresh in there, so the form will be repainted.  Try commenting that out.  If that does it, then I would just refresh MyTag and not the whole form.

Jim.
0
 

Author Comment

by:peispud
ID: 37750430
If I comment out the refresh, then the screen doesn't flicker.  But the data in the field / column [MyTag] does not represent the table data.

Can I just refresh that column?  If so how?
0
 

Author Comment

by:peispud
ID: 37750439
By the way,  .... This is a continuous form in Access 2010
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 58
ID: 37750453
Sorry, my brain is really not engaged today.

Do this at the end and see if this does it for you:

Application.Echo False
Me.Refresh
Application.Echo True
Me.Repaint

The continuous form may be a problem though... I remember something eith echo off doesn't quite work right with continuous forms.

Jim.
0
 
LVL 58
ID: 37750457
BTW, if that doesn't work, then there's another way we can go at it.

Jim.
0
 

Author Comment

by:peispud
ID: 37750475
Nope,  That doesn't work..  Screen still flashing with this continuous form.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 37750682
First, ...lets clean up the code...

a. I am not quite sure why the NZ() is in there... because the way you have it,...if it is null, you will insert a Zero "0"
b. I am not sure how SelText and SelLenght are working if you are not setting focus to the control first

Dim rs As DAO.Recordset
Set rs = GetRecordSet(Me.[Stock #])
If rs.RecordCount = 0 Then
    Exit Sub
End if

rs.Edit

If LCase(rs![MyTag]) = "y" Then
    rs![MyTag] = "":
Else
    rs![MyTag] = "Y"
End If

rs.Update
rs.Close
Set rs = Nothing
MyTag.SelLength = 0
MyTag.SelStart = 0
Refresh

OK, ...now that the code follows the normal structure, it is more readable and indented....

1. My first question would be if using Requery instead of Refresh fixes the flashing?

2. Why all the recordset stuff just to change one value in one record?
Consider using SQL and updating the table more directly.
In most cases, SQ is always much faster than using a recordset...
Something like this roughly:

CurrentDb.Execute "UPDATE YourTable SET YourTable.MyTag = IIF(LCase(YourTable.MyTag)='y','','Y')", dbFailOnError
'MyTag.SetFocus
MyTag.SelLength = 0
MyTag.SelStart = 0
Refresh


or
CurrentDb.Execute "UPDATE YourTable SET YourTable.MyTag = IIF(LCase(YourTable.MyTag)='y','','Y')", dbFailOnError
'MyTag.setFocus
MyTag.SelLength = 0
MyTag.SelStart = 0
Requery


3. Do you mean "Flashes", ...meaning it flashes *once*
...or do you mean it "Flickers" (flashes more than once)?

4. is the "Flashing" a dealbreaker?
(If someone hands you 400 oz Gold bar, do you care if their fingernails are dirty?)
;-)

JeffCoachman
0
 

Author Comment

by:peispud
ID: 37754688
Mr JeffCoachman

"Requery"  satisfies my requirements.   Now, only the affected row flashes (almost unnoticeable)   at times.   That's 99% of what I want.  

You made my day!!

You answered my question AND you went the extra mile.  I will definitely look into your other  advice.  I will try it this evening.

Thank you sir.

Ps.. Please do not feel embarrassed to hand over 400 oz of Gold bar just because your fingernails are dirty.  I can handle that. :)
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37754743
<Please do not feel embarrassed to hand over 400 oz of Gold bar just because your fingernails are dirty.  I can handle that. :)>
LOL!
Now you made my day...
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37754773
Oh and to be sure, you can see the help files on:
Requery
Refresh
Repaint

These commands are all commonly confused...
No one command is always "Better" under all circumstances...
0

Featured Post

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.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 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