Hi! This is a problem I have: I have an Orderform and an OrderDetails
form. I will have the user register a sparepartnr in the OrderDetails
form, but only if that number doesn't exist already. If it exist I'll
have a messagebox popUp and when he clicks ok I'll set the focus on
the actual field in the OrderDetails form, which is the fifth field on
the line. But where do I go wrong? It all works fine, except that I
can't seem to set the focus when returning from the messagebox!
Private Sub SparePartnr_Aft erUpdate()
On Error GoTo Err_NrAU
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordse t(
"SELECT DISTINCT OrderID,DetailI D,ItemID,SpareP artnr
FROM tblDetail
WHERE SparePartnr = '" & Me!SparePartnr & "'", dbOpenDynaset)
If rs.EOF Then
MsgBox "SparePartn r registered!", vbInformation + vbOKOnly,
"THANKS!"
Else
DoCmd.Beep
MsgBox "A sparepart with identical nr exists!" & Chr(13) _
& "Itemnr: " & rs!ItemID & Chr(13) _
& "Linenr: " & rs!DetailID & Chr(13) _
& "SparePartn r: " & rs!SparePartnr, vbCritical + vbOKOnly,
"¡¡¡ALERT!! !"
//This must surely be wrong?:[color=blue]
>With Me
>.SparePartnr.S etFocus
> End With[/color]
End If
rs.Close
db.Close
Exit_NrAU:
Exit Sub
Err_NrAU:
MsgBox Err.Source & Chr(13) _
& Err.Number & " " & "SparePart/SparePartnrAU" & Chr(13) _
& Err.Description , vbCritical + vbOKOnly
Resume Exit_NrAU
End Sub
form. I will have the user register a sparepartnr in the OrderDetails
form, but only if that number doesn't exist already. If it exist I'll
have a messagebox popUp and when he clicks ok I'll set the focus on
the actual field in the OrderDetails form, which is the fifth field on
the line. But where do I go wrong? It all works fine, except that I
can't seem to set the focus when returning from the messagebox!
Private Sub SparePartnr_Aft erUpdate()
On Error GoTo Err_NrAU
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordse t(
"SELECT DISTINCT OrderID,DetailI D,ItemID,SpareP artnr
FROM tblDetail
WHERE SparePartnr = '" & Me!SparePartnr & "'", dbOpenDynaset)
If rs.EOF Then
MsgBox "SparePartn r registered!", vbInformation + vbOKOnly,
"THANKS!"
Else
DoCmd.Beep
MsgBox "A sparepart with identical nr exists!" & Chr(13) _
& "Itemnr: " & rs!ItemID & Chr(13) _
& "Linenr: " & rs!DetailID & Chr(13) _
& "SparePartn r: " & rs!SparePartnr, vbCritical + vbOKOnly,
"¡¡¡ALERT!! !"
//This must surely be wrong?:[color=blue]
>With Me
>.SparePartnr.S etFocus
> End With[/color]
End If
rs.Close
db.Close
Exit_NrAU:
Exit Sub
Err_NrAU:
MsgBox Err.Source & Chr(13) _
& Err.Number & " " & "SparePart/SparePartnrAU" & Chr(13) _
& Err.Description , vbCritical + vbOKOnly
Resume Exit_NrAU
End Sub
Comment