Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Set Focus to control

$
0
0
Hi All,

I have a control on my form that looks up a value in a linked table. The goal was to ensure that a product part number was scanned in at the previous station before proceeding. Right now, it does that but if the part number is not located/keyed in wrong, it still saves the record. I would like to re-select the control (CathodeID) in the event that the part number is not found. I have the below code. Any help is much appreciated.

Code:

Private Sub CathodeID_LostFocus()
            Dim myCartridgeID As String
            myCartridgeID = Me.CathodeID.Text
           
            If Len(Trim(myCartridgeID)) > 0 Then

 
            Dim db As DAO.Database
            Dim myRecordSet As DAO.Recordset
            Dim MySQL As String
           
            'Open connection to current Access database
            Set db = CurrentDb()
           
            'Create SQL statement to retrieve value from GST table
            MySQL = "select * From [PottingIn] Where [CathodeIDIn] = " & """" & Me.CathodeID.Text & """"
           
            Set myRecordSet = db.OpenRecordset(MySQL)
           
            'Retrieve value if data is found
            If myRecordSet.EOF = False Then
              'do nothing
            Else
              MsgBox ("This Cathode was not Potted In!")
         
            End If
           
                               
            myRecordSet.Close
            Set myRecordSet = Nothing
           

            End If
End Sub

Thanks in advance!,
Audra

Viewing all articles
Browse latest Browse all 13329

Latest Images

Trending Articles



Latest Images