A
AFSSkier
How can I do a requery or error message "change to new sceen", when a user
queries one sku number. Then queries another without changing record pages in
a form. For example, if they key in the first sku number 12345 & all of the
fields are populated, then 23456 & the null fields do not requery. Capturing
the data from the previous sku number. We have asked that they change to a
new record screen, but sometimes forget. I have included the LostFocus code
below.
Private Sub Code_LostFocus()
Dim rst As Recordset
Dim db As Database
Dim dblItem As Double
On Error GoTo HandleErrors
If Me.Code.Text > 0 Then
dblItem = Me.Code.Text
Let mstrQuery = "Select * from ItemData where ITEMNO = " & _
"" & dblItem & ""
Set db = CurrentDb()
Set rst = db.OpenRecordset(mstrQuery)
Me.Pack.SetFocus
Me.Pack.Text = rst!Pack
Me.Size.SetFocus
Me.Size.Text = rst!Size
Me.Description.SetFocus
Me.Description = rst!Desc
‘etc., etc.
If IsNull(rst![5200AMT]) Then GoTo CB2:
Me.GMRTL.Text = rst![5200AMT]
Me.GMQTY.SetFocus
Me.GMQTY.Text = rst![5200QTY]
CB2:
Me.GRORTL.SetFocus
If IsNull(rst![0141AMT]) Then GoTo CB3:
Me.GRORTL.Text = rst![0141AMT]
Me.GROQTY.SetFocus
Me.GROQTY.Text = rst![0141QTY]
‘etc., etc.
CB7:
Me.CLPFLAG.SetFocus
If IsNull(rst![CLP-FLAG]) Then GoTo CB8:
Me.CLPFLAG.Text = rst![CLP-FLAG]
CB8:
Me.OI.SetFocus
End If
ExitHere:
If Not rst Is Nothing Then rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub
HandleErrors:
MsgBox Err.Description
Resume ExitHere
End Sub
queries one sku number. Then queries another without changing record pages in
a form. For example, if they key in the first sku number 12345 & all of the
fields are populated, then 23456 & the null fields do not requery. Capturing
the data from the previous sku number. We have asked that they change to a
new record screen, but sometimes forget. I have included the LostFocus code
below.
Private Sub Code_LostFocus()
Dim rst As Recordset
Dim db As Database
Dim dblItem As Double
On Error GoTo HandleErrors
If Me.Code.Text > 0 Then
dblItem = Me.Code.Text
Let mstrQuery = "Select * from ItemData where ITEMNO = " & _
"" & dblItem & ""
Set db = CurrentDb()
Set rst = db.OpenRecordset(mstrQuery)
Me.Pack.SetFocus
Me.Pack.Text = rst!Pack
Me.Size.SetFocus
Me.Size.Text = rst!Size
Me.Description.SetFocus
Me.Description = rst!Desc
‘etc., etc.
If IsNull(rst![5200AMT]) Then GoTo CB2:
Me.GMRTL.Text = rst![5200AMT]
Me.GMQTY.SetFocus
Me.GMQTY.Text = rst![5200QTY]
CB2:
Me.GRORTL.SetFocus
If IsNull(rst![0141AMT]) Then GoTo CB3:
Me.GRORTL.Text = rst![0141AMT]
Me.GROQTY.SetFocus
Me.GROQTY.Text = rst![0141QTY]
‘etc., etc.
CB7:
Me.CLPFLAG.SetFocus
If IsNull(rst![CLP-FLAG]) Then GoTo CB8:
Me.CLPFLAG.Text = rst![CLP-FLAG]
CB8:
Me.OI.SetFocus
End If
ExitHere:
If Not rst Is Nothing Then rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub
HandleErrors:
MsgBox Err.Description
Resume ExitHere
End Sub