Re: Setfocus in on change event hangs

alicejwz

Registered User.
Local time
Today, 21:26
Joined
Jul 9, 2003
Messages
91
Re: Setfocus in on change event hangs

Hi everyone,

I was wondering if anyone could some insight on my problem.

I'm using AC2K and SQL Server 2K. I copied my FE onto the user's machine.
The user's machine has similiar storage space & RAM and configuration as
mine. There are two text boxes on the form w/ on change events When I try
test the code it hangs from 8 seconds to 30 seconds on both of these
controls.
I stepped thru the code it ran Exit Sub in the subroutines and hangs.

I also removed all the code except .setfocus in the change event and it still hangs.


Here is my code:
Private Sub msp_barcode_Change()
On Error GoTo Err_msp_barcode_Change
Dim bag_n As Integer
Dim get_prev_bag_info As New ADODB.Command
Call load_const

If Len(Trim(Me!msp_barcode.Text)) = CInt(work_ord_num_length) + CInt(work_ord_line_num_length) Then
Me!work_ord_num.Value = Left(Me!msp_barcode.Text, 9)
Me!work_ord_line_num.Value = Right(Me!msp_barcode.Text, 3)
Call get_bag(Left(Me!work_ord_num.Value, 6), Me!work_ord_line_num.Value, get_prev_bag_info)
Set get_prev_bag_info = Nothing

If Me!bag_num.Value <> "1" Then
Me!unb_bag_quantity.SetFocus

Else
Me!material_lotnum.Value = ""
Me!insert_lotnum.Value = ""
Me!mfg_dt.Value = ""
Me!material_lotnum.SetFocus
End If
End If


Exit_msp_barcode_Change:
Exit Sub

Err_msp_barcode_Change:
MsgBox err.Description
Resume Exit_msp_barcode_Change
 
Missing an else

Not sure if it is relevant but If you have an
If...then
then I think it is always wise to have an Else
before the final End if

You are missing one. This shouldn't matter but I as a possible it may fail there.
The other suggestion is that after you have set the new focus the system may not know you are ready to view the form again. Try a refresh after the setfocus.
 
Alice,

The OnChange event fires after EACH character is entered. I think you
should get the entire entry using the AfterUpdate event.

Wayne
 
Hi Brian & Wayne,

Thanks for your reply.
I'm not sure what is going on. The two user's machines both having the same problem. For now I'll check something else before I get back to the code.
Hope you'll around for me to ask more questions.
Thanks!
Alice
 
Hi,

After copying FE on four more computers two are XP and two are W2K. They all hang when running the on change event w/ setfocus of the controls in the form. But on my machine it ran fine. Is there some of settings I need change on other machines?Where should I look to find the possible cause(s)?

Thank you!
 
Alice,

For starters, move your code to the AfterUpdate event. Unless you have
one-character barcodes, you don't want the code to fire on EVERY
character of the barcode.

Wayne
 

Users who are viewing this thread

Back
Top Bottom