Wait after update a field en display message

Bieke

Member
Local time
Today, 20:39
Joined
Nov 24, 2017
Messages
78
Hello,

I want to scan 2 labels with a barcode reader and check if they have the same code.
I have 2 fields to where i scan the 2 labels, first i scan label 1 in field 1, with the event "Private Sub LBL1_AfterUpdate()" i write a text to an info field 'scan label 2' then i set the focus to label 2, then i also scan this label 2 in field 2. I compare the 2 barcodes and when they are identical i want to write a text to the info field 'Labels identical' this text must hold for 1 second in the infofield and then the text in infofield has to change to 'Scan label 1'.
The problem now is that i don't see the first text 'Label identical' but after 1 sec it shows the text 'Scan label 1'
Why does the text not appear

Thanks in advance.
Bieke

This is my code:

Private Sub LBL1_AfterUpdate()
LBL2.SetFocus
[Info] = "Scan Label 2"
End Sub

Private Sub LBL2_AfterUpdate()
If LBL1 = LBL2 Then
[Info] = "Labels identical!"
Sleep 1000
[Info] = "Scan Label 1"
Else
[Info] = "Labels NOT identical!"
Sleep 1000
[Info] = "Scan Label 1"
End If

End Sub
 
why even use the message SCAN LABEL?
they know to scan in box 1 , then scan in box 2.

then you only need 1 message: correct or NOT correct.
 
Code:
Private Sub LBL1_AfterUpdate()
   LBL2.SetFocus
  TestBoth
End Sub

Private Sub LBL2_AfterUpdate()
  TestBoth
End Sub

sub TestBoth
If LBL1 = LBL2 Then
    [Info] = "Labels identical!"
Else
     [Info] = "Labels NOT identical!"
End If
end sub
 
why even use the message SCAN LABEL?
they know to scan in box 1 , then scan in box 2.

then you only need 1 message: correct or NOT correct.
The operator has to follow these instructions on the screen otherwise thinks go wrong.
 
The operator has to follow these instructions on the screen otherwise thinks go wrong.
Surely if you scan label1 then scan label2 and tell them to scan label1 from the afterupdate of label2, then you are in an infinite loop?
When do you stop following the messages?
 
Code:
Private Sub LBL1_AfterUpdate()
   LBL2.SetFocus
  TestBoth
End Sub

Private Sub LBL2_AfterUpdate()
  TestBoth
End Sub

sub TestBoth
If LBL1 = LBL2 Then
    [Info] = "Labels identical!"
Else
     [Info] = "Labels NOT identical!"
End If
end sub
And where is the delay of 1 sec?
 
Surely if you scan label1 then scan label2 and tell them to scan label1 from the afterupdate of label2, then you are in an infinite loop?
When do you stop following the messages?
It is already a loop, how to stop is not important. My problem is displaying the text.
If you can make an infinity loop that displays two different texts displaying in the same field alternating with a pause of 1 sec between 2 texts should be a nice solution. It is a challenge 😉
 
You can introduce a code delay using either the Sleep function or Application.Wait function.

This link is for Excel but works equally well in Access.

 
I already use sleep in my code as you can see. The problem is that the message before the sleep will not be written to the textbox.
 
I already use sleep in my code as you can see. The problem is that the message before the sleep will not be written to the textbox.

I'm thinking that the answer to that is "no." Tell you what to try: Just after you write what you want, do a Me.Repaint before you sleep. The problem is that writing to the textbox and painting that box to the screen are actually two distinct steps, and forced screen painting is often avoided because it causes flickering. Unfortunately, controls don't have a .Repaint method so you can't selectively repaint. You have to repaint the form.
 
I'm thinking that the answer to that is "no." Tell you what to try: Just after you write what you want, do a Me.Repaint before you sleep. The problem is that writing to the textbox and painting that box to the screen are actually two distinct steps, and forced screen painting is often avoided because it causes flickering. Unfortunately, controls don't have a .Repaint method so you can't selectively repaint. You have to repaint the form.
Ok, i will test it. I hope it works. Thank u for your help.
 
Ok, i will test it. I hope it works. Thank u for your help.
Hello Doc, i’have tested your solution and it is working fine. Thank u very much, it saves me a lot of time. Regards Bieke.
 
Glad I could help. Good luck moving forward!
 

Users who are viewing this thread

Back
Top Bottom