Form not updating immediately

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form where I'm using the DSUM function within a lost focus event.
For some reason it doesn't update immediately when I leave the field.
Sometimes I actually have to hit the arrow twice to move to the next record.
I will give the details of the code involved here, any help would be greatly
appreciated...

Private Sub TxtLotNumber_Change()
[TxtOriginalQty] = DLookup("[OriginalQty]", "[API_LOT]", "[LotNumber] =
Forms![Enter API Sublots]![TxtLotNumber]")
[TxtOriginalUnits] = DLookup("[Units]", "[API_LOT]", "[LotNumber] =
Forms![Enter API Sublots]![TxtLotNumber]")
End Sub

Private Sub TxtQtyDispersed_LostFocus()
TxtQtyOnHand = [TxtOriginalQty] - DSum("[QtyDispersed]", "API_SUBLOT",
"[TxtLotNumber]=[LotNumber]")
TxtQtyOnHand.Requery
End Sub

I hope this is enough information to go on...

Thanks!
 
I have a form where I'm using the DSUM function within a lost focus event.
For some reason it doesn't update immediately when I leave the field.
Sometimes I actually have to hit the arrow twice to move to the next record.
I will give the details of the code involved here, any help would be greatly
appreciated...

Private Sub TxtLotNumber_Change()
[TxtOriginalQty] = DLookup("[OriginalQty]", "[API_LOT]", "[LotNumber] =
Forms![Enter API Sublots]![TxtLotNumber]")
[TxtOriginalUnits] = DLookup("[Units]", "[API_LOT]", "[LotNumber] =
Forms![Enter API Sublots]![TxtLotNumber]")
End Sub

Private Sub TxtQtyDispersed_LostFocus()
TxtQtyOnHand = [TxtOriginalQty] - DSum("[QtyDispersed]", "API_SUBLOT",
"[TxtLotNumber]=[LotNumber]")
TxtQtyOnHand.Requery
End Sub
are your ControlNames the same as the FieldNames?

Me.ControlName referes to the control
Me!FieldName referes to the field

if your DLookup refers to the control, then the Field gets updated
after the lost focus
 
The DLookup refers to the controls...I try and use a different name for all
of the field names, such as TxtOriginalQty. So, I am using the correct
format then, right? If so, then what else could it possibly be?

Andi Mayer said:
I have a form where I'm using the DSUM function within a lost focus event.
For some reason it doesn't update immediately when I leave the field.
Sometimes I actually have to hit the arrow twice to move to the next record.
I will give the details of the code involved here, any help would be greatly
appreciated...

Private Sub TxtLotNumber_Change()
[TxtOriginalQty] = DLookup("[OriginalQty]", "[API_LOT]", "[LotNumber] =
Forms![Enter API Sublots]![TxtLotNumber]")
[TxtOriginalUnits] = DLookup("[Units]", "[API_LOT]", "[LotNumber] =
Forms![Enter API Sublots]![TxtLotNumber]")
End Sub

Private Sub TxtQtyDispersed_LostFocus()
TxtQtyOnHand = [TxtOriginalQty] - DSum("[QtyDispersed]", "API_SUBLOT",
"[TxtLotNumber]=[LotNumber]")
TxtQtyOnHand.Requery
End Sub
are your ControlNames the same as the FieldNames?

Me.ControlName referes to the control
Me!FieldName referes to the field

if your DLookup refers to the control, then the Field gets updated
after the lost focus
 
I also set up another field just to test the DSUM funtion and the updates are
not consistent. Sometimes it will update the first time I leave the field of
a record, but then if I change the value and leave again...it won't update.
At this point I have to start changing records for it to update (and this
usually involves hitting the next record arrow twice)...

Andi Mayer said:
I have a form where I'm using the DSUM function within a lost focus event.
For some reason it doesn't update immediately when I leave the field.
Sometimes I actually have to hit the arrow twice to move to the next record.
I will give the details of the code involved here, any help would be greatly
appreciated...

Private Sub TxtLotNumber_Change()
[TxtOriginalQty] = DLookup("[OriginalQty]", "[API_LOT]", "[LotNumber] =
Forms![Enter API Sublots]![TxtLotNumber]")
[TxtOriginalUnits] = DLookup("[Units]", "[API_LOT]", "[LotNumber] =
Forms![Enter API Sublots]![TxtLotNumber]")
End Sub

Private Sub TxtQtyDispersed_LostFocus()
TxtQtyOnHand = [TxtOriginalQty] - DSum("[QtyDispersed]", "API_SUBLOT",
"[TxtLotNumber]=[LotNumber]")
TxtQtyOnHand.Requery
End Sub
are your ControlNames the same as the FieldNames?

Me.ControlName referes to the control
Me!FieldName referes to the field

if your DLookup refers to the control, then the Field gets updated
after the lost focus
 
The DLookup refers to the controls...I try and use a different name for all
of the field names, such as TxtOriginalQty. So, I am using the correct
format then, right? If so, then what else could it possibly be?

this is not necessary (but helps to see if its a field or a control)
add a Me.Refresh

when writing code in a form use the magic Me.
you get all the properties which are available on the form

Private Sub TxtLotNumber_Change()
Me.TxtOriginalQty = DLookup("[OriginalQty]",................
.....
Me.Refresh
end sub
 
Andi,

I actually put the Me.Refresh before the DSUM calculation and everything is
updating correctly now. Here is what I did...

Private Sub TxtQtyDispersed_LostFocus()
Me.Refresh
Me.TxtQtyOnHand = TxtOriginalQty - DSum("[QtyDispersed]", "API_SUBLOT",
"[TxtLotNumber]=[LotNumber]")
End Sub

Thanks for the suggestion!

Zaz

Andi Mayer said:
The DLookup refers to the controls...I try and use a different name for all
of the field names, such as TxtOriginalQty. So, I am using the correct
format then, right? If so, then what else could it possibly be?

this is not necessary (but helps to see if its a field or a control)
add a Me.Refresh

when writing code in a form use the magic Me.
you get all the properties which are available on the form

Private Sub TxtLotNumber_Change()
Me.TxtOriginalQty = DLookup("[OriginalQty]",................
.....
Me.Refresh
end sub
 
Back
Top